From nobody Wed Nov 27 04:34:36 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5AD13DDDD; Mon, 14 Oct 2024 06:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728886395; cv=none; b=EY8Snwwr2Phta3Z/bjqV0fC7bG8+WYeQt1ydUyOY6fo5NB3r+jpx/IeeRaOzM7U66HBW7NMC2ifo0yqkYhUJY3TqczkiSGFqT2OII3m1S5TiYVyKNRGr0ylruroVltCwVNhUUO9bDWFo62AvKLFJNmpCToGhUopJ003XJntgbfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728886395; c=relaxed/simple; bh=K6h8tAeieFW0Cznusyfb6RjH0CT98np2AQWV/rfuR5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N9i/E9jm4SSWOmwXSTRw3MlWGSZkIVj8J3j6XIzSr8BLcSGazxjNrPQslCcZW3u9TQwbGysGzJlBNPeUdWWBWSMHsJ0ErMelNfudeVEMvYMMueucA8+RkNYkNquZkbrrv3JpkYCG7SrKN0OctWyGRbIHemQVTeBvsL3AfYeAdQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=VTPBY/py; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VTPBY/py" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4758196C; Mon, 14 Oct 2024 08:11:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728886285; bh=K6h8tAeieFW0Cznusyfb6RjH0CT98np2AQWV/rfuR5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTPBY/pytA8Jrjj+wgU+YfLt+0Y7hQw3LRAFSjCxqe2OMTOieJmIHrhNhXcMwq5hO 9tWFE2HlzNCGLtABCX1NFB3AkxLgsgZUvB1Eauri3+uRceBD7DMd7E5nQHLg39A1+6 +GAO6hHzRhvCajIZNmiAfPquC9XBuH6VbF69h5zU= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Javier Carrasco , Umang Jain , stable@vger.kernel.org Subject: [PATCH v2 1/2] staging: vchiq_arm: Utilise devm_kzalloc() for allocation Date: Mon, 14 Oct 2024 11:42:55 +0530 Message-ID: <20241014061256.21858-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014061256.21858-1-umang.jain@ideasonboard.com> References: <20241014061256.21858-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The struct vchiq_arm_state 'platform_state' is currently allocated dynamically using kzalloc(). Unfortunately, it is never freed and is subjected to memory leaks in the error handling paths of the probe() function. To address the issue, use device resource management helper devm_kzalloc(), to ensure cleanup after its allocation. Cc: stable@vger.kernel.org Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 29e78700463f..146442a3552c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -285,7 +285,7 @@ vchiq_platform_init_state(struct vchiq_state *state) { struct vchiq_arm_state *platform_state; =20 - platform_state =3D kzalloc(sizeof(*platform_state), GFP_KERNEL); + platform_state =3D devm_kzalloc(state->dev, sizeof(*platform_state), GFP_= KERNEL); if (!platform_state) return -ENOMEM; =20 --=20 2.45.2 From nobody Wed Nov 27 04:34:36 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A078E140E34; Mon, 14 Oct 2024 06:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728886396; cv=none; b=sjQUSWucvHZqHjgJ7vwBrf5GtjSqlZKlK376xlpifmxR+5leWT3Sehj6y4gsJRu4sXf4Vs2yILz9RpDYVp0TF3Mqrt9NRlu4s+Va2RzlGlTyinYUCyAOZVIqt7apyIYqJMDbx5GWctVmaMbJqOWYuJ5GwiMIyqRON0kgBQtBYTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728886396; c=relaxed/simple; bh=R0ESmbzFoRfF6h/C7QRmHY0ayx/GIqhuCW301plDmS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kcsy+wgenWh4MiNG4cSSI76Jaasf70OhXLwuLs3VXt1L4muY+cr9IADqnNEPKnyPoCGMcgNQV+IqQmNdoGiGRfe5HwmeqmreZteDZvt/wVXLf+GmX0cE80rExDdkjRDpszmfC19xLDyWuCheMIy8haRf0eMZrrRHsl4jILBb87I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=l1Mga8Ra; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l1Mga8Ra" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C536C1449; Mon, 14 Oct 2024 08:11:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728886287; bh=R0ESmbzFoRfF6h/C7QRmHY0ayx/GIqhuCW301plDmS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1Mga8RaGaPAhu/5YnUVxk6lyC17G8cY2tZ3L/xPmkJd/wXJlh1mQ5SFw18M6F/rq I1Q26HcpGYWWFxibC0YMkrYOCCyIb7+rYlvhpIv10PuLqliU8VdgCKt63LjHej6rfz w0WMgH5AabMaHUeW3OHtFhGylSHfBGgS+ds811Bk= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Javier Carrasco , Umang Jain , stable@vger.kernel.org Subject: [PATCH v2 2/2] staging: vchiq_arm: Utilize devm_kzalloc() for allocation Date: Mon, 14 Oct 2024 11:42:56 +0530 Message-ID: <20241014061256.21858-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014061256.21858-1-umang.jain@ideasonboard.com> References: <20241014061256.21858-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The struct drv_mgmt 'mgmt' is currently allocated dynamically using kzalloc(). Unfortunately, it is subjected to memory leaks in the error handling paths of the probe() function. To address this issue, use device resource management helper devm_kzalloc(), to ensure cleanup after the allocation. Cc: stable@vger.kernel.org Fixes: 1c9e16b73166 ("staging: vc04_services: vchiq_arm: Split driver stati= c and runtime data") Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 146442a3552c..373cfdd5b020 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1344,7 +1344,7 @@ static int vchiq_probe(struct platform_device *pdev) return -ENOENT; } =20 - mgmt =3D kzalloc(sizeof(*mgmt), GFP_KERNEL); + mgmt =3D devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL); if (!mgmt) return -ENOMEM; =20 @@ -1402,8 +1402,6 @@ static void vchiq_remove(struct platform_device *pdev) =20 arm_state =3D vchiq_platform_get_arm_state(&mgmt->state); kthread_stop(arm_state->ka_thread); - - kfree(mgmt); } =20 static struct platform_driver vchiq_driver =3D { --=20 2.45.2