From nobody Tue Nov 26 17:35:30 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 5DD13208D7A; Wed, 16 Oct 2024 13:02:38 +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=1729083759; cv=none; b=GjP0Tu9NqV36RNGPeWT83cEtva8AxHV272H6hh//1d/mD1SI5vIYeyYLR2RmBSwffnkM0jFyoJ34frwIQdbmpav76MsYuwVtDxI69xNho2cyWc0WIcdbfAM7201gVTOofX/NYaRTGio3UrzSFT02fK3s0NFicrxfDwhKM/YgQww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729083759; c=relaxed/simple; bh=bDAzz8rEagZA0Ehp3iX6ifhXsUe2CA1xnyoJA1RJ0iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RNYmY+6SNlR9gAU4BC1VAz33FB7ikickwB8RQ38P2lg97fSZXt9dYQSMjMRBjg/QEwo1CTk100FEjGHF0Lf9QCBfkSc0p4kDMLH2arVCQAfiVQdzXj6CfxfNVIWxzHYv3qMukfEC38klJcNxOyTVOl4o/VShygJljSxPQG5N0MQ= 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=VL1qOkup; 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="VL1qOkup" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B2444F50; Wed, 16 Oct 2024 15:00:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729083653; bh=bDAzz8rEagZA0Ehp3iX6ifhXsUe2CA1xnyoJA1RJ0iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VL1qOkupAdXhqRkKe0reDiXstfkIcizMYur9p3i/iRH8ceZ1I8O13eefEBOaWzUOg ZZhI80xe2xScgbKeXShsR2buVSNPm1De8aLqaTYVTBB2cKt3TMqvqpby4D5FPwNpFI z/odzB2VRn93gRvJvCfZe4ItWpiKtHZbBdwr8+hQ= 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 , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH v4 1/2] staging: vchiq_arm: Use devm_kzalloc() for vchiq_arm_state allocation Date: Wed, 16 Oct 2024 18:32:24 +0530 Message-ID: <20241016130225.61024-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241016130225.61024-1-umang.jain@ideasonboard.com> References: <20241016130225.61024-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 Tue Nov 26 17:35:30 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 2A24E209F4B; Wed, 16 Oct 2024 13:02:40 +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=1729083762; cv=none; b=Abq+LFWEzMviehNE9KeGm5EzNGyqVmb7ILiCg9Pwf/AHu93idF8bq8JFJnhERIovWUOdthTGB7aYk20aTWNB8tu+Jv7h/zCXP99Fhm2RFrY4FRwzuAMjzwdMEz8HnTomWPjri95ZW0sG4oVPf3Xtgkri3jNpNGyDOdQAJgG5kT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729083762; c=relaxed/simple; bh=eFZWbOo+TJEgq/Jip7gO5D6X+BXYGORK47hl/bD23Ec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JTWpp127Pb9cmS2MujDC0du+afFJDOhel5IOIZc2Vsu7tueDikP6jqHT9g030WWKQAa9WJ+xoC+m/lYI5FDxIXzkOqpxmcA1FiTMhzhcKZzg/q/h5a8DIWOEZv1zeNgHg2wlrz2jetRThggxC8ACciROeKkYPHjeBRoka0CHopc= 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=cF4pGfVN; 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="cF4pGfVN" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 21533F86; Wed, 16 Oct 2024 15:00:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729083656; bh=eFZWbOo+TJEgq/Jip7gO5D6X+BXYGORK47hl/bD23Ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cF4pGfVNL10E8IRO47Cp96CaNFhK5FCkk7fM0g1yOKYCHXKFpPa5lGY6POiXVJR8e j4Zj3qwMWy/keHdk9pWH8tUCQ8RCoSaCBdSm//8DQHrPvQFtBf1KVOLIv3n8siionG 1bdxZnCsgj00p/pIOuQmxKlirjifL1h/E7g7ZHew= 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 , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH v4 2/2] staging: vchiq_arm: Use devm_kzalloc() for drv_mgmt allocation Date: Wed, 16 Oct 2024 18:32:25 +0530 Message-ID: <20241016130225.61024-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241016130225.61024-1-umang.jain@ideasonboard.com> References: <20241016130225.61024-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