From nobody Wed Nov 27 04:31:23 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 DAEB0231CB3; Sun, 13 Oct 2024 17:16:30 +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=1728839792; cv=none; b=CQ0enHX8t02Dmljlxgsl1msqvvd02aVUrKKubW1AQ4FvU+FnJA78OvXJCKXi6R+vxeDzsQZhBNqhtWzZ7KVb5JWfcrs5/lPFY+tFQr3wH4uJsl0BAzTgrJrCImT8qlSL9S0c7SCK4ZQcWqhZW66KvDNrYCcMDOK+v+3vp3Je3mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728839792; c=relaxed/simple; bh=lszqkzooi/14FP99VptZF43wt7uBIMlNx7+MBmNiqIc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OMnyMlKh0Sfw8whLWesyxMQs2v/oMQjlwNDP+FWQfeCXyf28Qnuib/qTDoX7PUrhVqEnnS07kZmgCNa4wxpnEKdf1/hwLBWiI4gKc+8wwp1Nq2B3ykyr5mj5x94lckSgUQe4/eIL+oXsB5WDNAIH1DiHRy2dyQqM3j4DVwekEZ0= 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=PuU6+da+; 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="PuU6+da+" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1AE774CE; Sun, 13 Oct 2024 19:14:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728839688; bh=lszqkzooi/14FP99VptZF43wt7uBIMlNx7+MBmNiqIc=; h=From:To:Cc:Subject:Date:From; b=PuU6+da+27o+EnRc06HCMOStCI3/M8zn4fintv8jUqifpgxnZxZlSW9rzf2tB+Rr9 C1X/Lm9pRUi9Pd0t9ThnIorPoH1JkLkGjJyH0P92i+nFcRdGRhtMq4tWMeboW7AoLH vCcylIg3Nyg6jqry69sobrpi+ajoTTPeCpFa4/1w= 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] staging: vchiq_arm: Utilize devm_kzalloc in the probe() function Date: Sun, 13 Oct 2024 22:46:13 +0530 Message-ID: <20241013171613.457070-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 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 two resources, 'mgmt' and 'platform_state' are currently allocated dynamically using kzalloc(). Unfortunately, both are subject to memory leaks in the error handling paths of the probe() function. To address this issue, use device resource management helper devm_kzalloc() for proper cleanup during 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 --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 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 29e78700463f..373cfdd5b020 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 @@ -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