From patchwork Wed Oct 16 13:02: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: 13838457 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 4528FD1AD55 for ; Wed, 16 Oct 2024 13:04:22 +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=KYlpXq9AEq+y8cvllgkmlwVE5s3nKMrXd6vVyci656E=; b=szbu6fdagFSqa9OYtJTmglJn/t oKIMnTWOsJxoh2b/ZrRQtHQ3HQxq5X7mZXBHFSozFTWvdv3bJyRf8f4f+1+T02k1lzX1AZoYJKUGI GTCT6i1EbmFolemLx4K4wfERKlG2YFobKsUlppZ9cyQ6tk9HKgX/goEgTGXOpstQLXLRUDa+NvDWp IoHP5Ubi2PtW0VX7Ci033t+2gVRBIn2WA8aHOYHDErB7J3Afbt9zlS2B69+h1Vt+iaE8iJphm0BYx ixo2dIh16d9wxWJfuTtr/8zO1TPSNXwD85qRj3iLb1zwt8g4bIK+sOpKpBQ+VcQy3UVkgiE9UdlJM AOk4dYtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t13hC-0000000Brci-0Iyn; Wed, 16 Oct 2024 13:04: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 1t13fk-0000000BrMX-3yHY; Wed, 16 Oct 2024 13:02:42 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241016_060241_144928_144D6744 X-CRM114-Status: UNSURE ( 9.97 ) 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 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; - platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); + platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL); if (!platform_state) return -ENOMEM;