From patchwork Mon Oct 14 06:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13834190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C75CCF259D for ; Mon, 14 Oct 2024 06:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Vi8JD9ec/8vckdGEY8cJbMc0hoGJXs6hBmFfhv9toVY=; b=IOE8+m9DB0igmaTPoHIz9vc4Ws 7RCEYpfRoZ8Dz3ZNCKis4V+8q6Fj0lqiAXVTOPcPubvIf2A4NMLoXat56G/smG3zdMf3JUDcTv/Ak zoG6ICr/o7KGLff/RmFzyGPkoFFDoaXdCyAuRUsR3jynxmaDMMm6KmKaGH9jNhHnEoZ1M+i+ec4xY 745U7R7umkYQXfho/h9OpYD3aqoJfOYgPOSoZIGP/kzjN7BUy8GEsGE9pPa4fqI1xDHOvFHran+EC iNyFCvfjyt8Ds+lWBfTFmlB0XVlE5toM+scogoFRPTXjQaI0ka8xFw13FuOLXZQzh3pV1wnE9gCmK Gx6Bnojw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0ELj-00000003rKg-3dyV; Mon, 14 Oct 2024 06:14:35 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0EKK-00000003r6Q-2rBy; Mon, 14 Oct 2024 06:13:10 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241013_231309_011028_C39C9AA8 X-CRM114-Status: UNSURE ( 9.57 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; - platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); + platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL); if (!platform_state) return -ENOMEM; From patchwork Mon Oct 14 06:12:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13834192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C785CF259D for ; Mon, 14 Oct 2024 06:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0X5gwEm+9GipfTfO2VKoIUmc4Ct+NDJQIwaKG9mVnG8=; b=F2fFisejBhvyOjuSkNXrX8iHXx /+TGGHdhcF/IJOOL1ElR1FBc0+yqTkTj2nMH1jYSv2bPQFjVMWTNXGJ+MuvsVtSj20Wo/17ZVLDR0 4cw+vjWeF4oV72taGz+gqGH5sMRwZ8KV94q1cK+J4WBRtQruBsaCEdzDLmAiR2h2p5eyjmqIimpco zmYfXSi4xqStotYDyR/E9Wua/rwxx7cca7p92s4T4YCSnj2ze651REl3ZLR3txA9p9tvQIGICJdgo ZmFiuq2tkT1TGEvpC0mmeO3gRs6kOGoJYid1x5VXZdke02mxpUYJjxjqUv0pe1avZZNn0z5utjSqS xXAeXn6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0EOa-00000003rf9-190q; Mon, 14 Oct 2024 06:17:32 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0EKL-00000003r6d-3iss; Mon, 14 Oct 2024 06:13:11 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241013_231310_085313_D067F1C8 X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 static 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; } - mgmt = kzalloc(sizeof(*mgmt), GFP_KERNEL); + mgmt = devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL); if (!mgmt) return -ENOMEM; @@ -1402,8 +1402,6 @@ static void vchiq_remove(struct platform_device *pdev) arm_state = vchiq_platform_get_arm_state(&mgmt->state); kthread_stop(arm_state->ka_thread); - - kfree(mgmt); } static struct platform_driver vchiq_driver = {