From patchwork Mon Oct 14 10:06:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13834596 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 DB8E4CFC534 for ; Mon, 14 Oct 2024 10:17:24 +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=ejN6iSIgERgljQpaM/YoCmUTYFpZ6wbHJbU8Ukl6BW8=; b=okQOH2I7i1m1yUUUk02l7B8ZPQ I//RLsF66tLj+/Kzf1RphDg7IYEupr7tWXgReRCnvDBRWeO7uDvZqjT3A9eTXd4VvE8lSFakuD9q1 A4a90+rgglMthMRGPA/Y0E32lYLFg+pxGmmZbhrPJTAVOh+RY8JVlZhaQHCHhS4vA98d15S9SY1vs yHUtWaUmrGFnBWVmilN83pybsju7XU9Eu0QNkX5285+ngn7lWo3RrdVGH7vp0x+fjFL5d0sSwGrbI euUNUBs/cWoO/SFV4WjDnGIY/KzXCCUfpgB1Qk+EaAlvCCMdWqVQNI5ygQxLtGpaGdwM6CGUamIYA 0S03dH6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0I8Y-00000004fi4-1lts; Mon, 14 Oct 2024 10:17:14 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0HyE-00000004dmo-1ZXB; Mon, 14 Oct 2024 10:06:38 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_030634_643629_CBFFC8DA X-CRM114-Status: UNSURE ( 9.80 ) 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. Fixes: 71bad7f08641 ("staging: add bcm2708 vchiq driver") 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 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; - 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 10:06:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13834599 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 B9328CFC538 for ; Mon, 14 Oct 2024 10:29:20 +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=W+DVhLDT4QHIqr9CjoxqFf8ytfKZ341oNtVP0bRzWPc=; b=K9Pl6qFy4+j5u2v7yzgsZPYie8 REr2y84fUN4b0MgRZ9aFxRLRz1lzYKcYS+KhdK52BbmLR4NKjkbvQWaWJOMUnCE+SrxRk3BzWXz6v X+FSZK564xUEJDdyqtiZQ8VeRXgK3rd+mSLhPulq9xn3KN5Ehrk+DOXZgjOnayvwfZltOGyo/ud6C GYVnBJwfu6ZeQyCwMWim+gc+szJUgCWr1j3zVQNXSZLnIxuYbLwEujZ1Wk3RzUd/6yYXxGUGwKp1i oRQuxeMdI2cWbGVzjFPKGIJqu07yua/vY5E3e2xNwDH7cyVQQS9z1INlVxpTQSpxUUiDTVBjCWwLl RxG4jJMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0IK6-00000004hNV-02xo; Mon, 14 Oct 2024 10:29:10 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0HyG-00000004do3-2nXJ; Mon, 14 Oct 2024 10:06:40 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_030636_898604_462BB127 X-CRM114-Status: GOOD ( 10.09 ) 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 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; } - mgmt = kzalloc(sizeof(*mgmt), GFP_KERNEL); + mgmt = devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL); if (!mgmt) return -ENOMEM; @@ -1397,8 +1397,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 = {