From nobody Wed Nov 27 02:25:27 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 96E50158DD8; Mon, 14 Oct 2024 10:06:34 +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=1728900396; cv=none; b=KoHchX+577UWiFm8Mc4e44SIgHQZ98Yfg93AgnovaH/PYjuZnTBnqcalhRQKiqxKgCO2TKxhwWjNbx8xXlQIxPeYdrrqtfG9vZ1WoqdJVjzFNREHaFOtxY9vLtNMKxz9KfFfQ1ppGAGmkumhL4sNZaGV5v3ZJQgJfHD92vFc0D8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728900396; c=relaxed/simple; bh=OG70jJR+91myI+hPfV/bHA4o5/PggLwB9TA01NFxDwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GQRt7B39F5t8bkHPKEhiBslUN+Vz/+bec2cXWwMfR1bT3Iocl8kt7AwwHWARfAz1o8SCOg+1tB2DessRXE64BLrhshTlDEsfKAWJ/BhmkM0j9YkF7UJJZxkjHY2LMma+pVvbjRroZT2uWWgZOiwuipdNrkNsXk7YvKcS1dPeSK0= 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=kdnrhXWv; 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="kdnrhXWv" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 361D796C; Mon, 14 Oct 2024 12:04:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728900292; bh=OG70jJR+91myI+hPfV/bHA4o5/PggLwB9TA01NFxDwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kdnrhXWvsk4jeVG/EosuAP9pGJUTtvHZC2UtcyFZytQ3PvX4deCU+W3hMxlYSkYY6 QZk1+uDwpJEjJ9KUKVCteB8STI98z2+zebY5r3MtSQJIPqaC6LgihQUXQM5BTydjif bVxlUXjnKoHcSQYtPCJpvgVRsUq107FW5KM6uIfI= 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 , Umang Jain , stable@vger.kernel.org Subject: [PATCH v3 1/2] staging: vchiq_arm: Utilise devm_kzalloc() for allocation Date: Mon, 14 Oct 2024 15:36:23 +0530 Message-ID: <20241014100624.104987-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014100624.104987-1-umang.jain@ideasonboard.com> References: <20241014100624.104987-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. Fixes: 71bad7f08641 ("staging: add bcm2708 vchiq driver") Cc: stable@vger.kernel.org Signed-off-by: Umang Jain Reviewed-by: Dan Carpenter --- 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 af623ad87c15..7ece82c361ee 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 02:25:27 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 1DA8415D5B6; Mon, 14 Oct 2024 10:06:36 +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=1728900398; cv=none; b=NOE5yPkx+cBZxDBp6THqwUGEyU33I24z++xrI5oE5O6sK9UYLm8+/lbzrt4uslX0L6hHRsP+666DWxF6e0CiYBpzt6DdQ/A2r7+bE1uHdZleAL3FZJzafRJFF5/bVluYXnZvYZKJQqPJFr0TV5BzljdsICO4rZIBeUoC+A2sbmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728900398; c=relaxed/simple; bh=uaq+VezdUHJKrUYtj9d7VcOn+0AYecZGUvHEZTIw4WY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAHEeb6tfbSmCZVIeDZA0+mLhm9FwO+m9mq3xbC82KwID4z/T3Qq8UgQ1r4Xm+9PoT+Tg8QoLOdWNMhyre0vJXKmSPDJdmsaDw6kpejVi/PNzMzJNbpUHR2ERipTwUe14doPZt3fy20ESnAFdc7amsnO5055RB7so+EGLkYk5nQ= 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=PLaQws46; 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="PLaQws46" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A086A1449; Mon, 14 Oct 2024 12:04:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728900294; bh=uaq+VezdUHJKrUYtj9d7VcOn+0AYecZGUvHEZTIw4WY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLaQws46jfL+o5Ua+94/BFY1mef7eOr6tAzSKlxIG5hujGe6A2NPODDUBkA91nUSh 1BsT6JrZREMf4IVGNEsdD7tsT0riBZpbyInuRS0cwKlV2pcQQUHXvsmrU1/jYobUHj /Tng7MrJwYBekMGK2msIITfQBUpCD0lIuWmSePPA= 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 , Umang Jain , stable@vger.kernel.org Subject: [PATCH v3 2/2] staging: vchiq_arm: Utilize devm_kzalloc() for allocation Date: Mon, 14 Oct 2024 15:36:24 +0530 Message-ID: <20241014100624.104987-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014100624.104987-1-umang.jain@ideasonboard.com> References: <20241014100624.104987-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 Reviewed-by: Dan Carpenter --- 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 7ece82c361ee..8412be7183fc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1343,7 +1343,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 @@ -1397,8 +1397,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