From patchwork Mon May 29 07:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13258267 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 16D44C77B7A for ; Mon, 29 May 2023 07:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eHI9Tz43a08Sh9L1UNSHr9FAkMsgqEux5T51PgxzBDE=; b=w0xsXBRipKEUeg 7vk1Z7U8h+hktE3e+nIWiHkt4T0w1CUdaBkmbNY3v0AmKQxVyMN0YpGiFUmLhh+xYOWPOKdc2XY83 QLyYp+TQ5Cb/fejsBHWp4drMkK07A5QRZ504g5Ib9Mp3vS7NrLtuPzze8nzrgIbiHiZ0wVyYXapi4 3AcN8PAs6CSPiFQ7jeKwNG8al/wCeF+0kApuUvbi0EUD+pH5FJ6F9WYkDSxSpI834vZ8KW7ub+72/ YJEEp7HB3mlpuzjx4YuWFLPX9TiLuEEUBvHEHjgwnzeNAEPFMddiCqi7n1x5cpDkkmhEMB+eytRqZ ekCOtEIKe8x5HvL+4A7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3XhB-009cGW-2C; Mon, 29 May 2023 07:53:37 +0000 Received: from smtp-25.smtpout.orange.fr ([80.12.242.25] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3Xh8-009cCy-0E for linux-arm-kernel@lists.infradead.org; Mon, 29 May 2023 07:53:36 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3Xh0qNNQ6bOsk3Xh0qatrx; Mon, 29 May 2023 09:53:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685346807; bh=H3ch+1sM2uCmnqikyZRtBFR3E4UWkyikm5gSoo9tMEw=; h=From:To:Cc:Subject:Date; b=Ca+i/7Xd8fUTtOSPS5ZtF6/eN31g6TQw804cqrMM2lMjXpHJ9myreRtfPe0MwTz5H gOwZ0qhXNQFMi8Vmb5TWrAlplx3j48gdpLdhvaoNgvx4QZj1bJrsQuOfcAmcMSTHXv 4fwrBXcJfSDMGMKkFVuLJzWhbBezJYol8FyxkAUxa8LxbHoTFUqVlf1yYjx7EBj795 OkfOXDBRObkLgAFMEWca4kMrXTi1z+xSV+9UmN2s85MhhnnrsGlgHIEztesd7bQuGo 0pzUzFUKdEEotX+ilQzPdO5Jw++pQ91CrHAy8IX6e64C6Ynx62yzVqV4LcmLQS/qQQ YdnIjkd3bMDMw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 29 May 2023 09:53:27 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Michal Simek , Rajan Vaja , Tejas Patel Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org Subject: [PATCH] soc: xilinx: Fix a memory leak in zynqmp_pm_remove() Date: Mon, 29 May 2023 09:53:24 +0200 Message-Id: <93ef923496b6c45a0baa59458099aed3a20b771a.1685346792.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_005334_265984_34AA3A56 X-CRM114-Status: GOOD ( 15.27 ) 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 'rx_chan' is known to be NULL here. Reverse the logic to free the mbox if it has been allocated. Fixes: ffdbae28d9d1 ("drivers: soc: xilinx: Use mailbox IPI callback") Signed-off-by: Christophe JAILLET --- 'rx_chan' may be NULL, but mbox_free_channel() handles it. Maybe it is more informative to keep a (useless) "if (rx_chan)" to tell that it may not be allocated. On my machine, compilation fails with gcc (Ubuntu 12.1.0-2ubuntu1~22.04): CC drivers/soc/xilinx/zynqmp_power.o drivers/soc/xilinx/zynqmp_power.c: In function ‘zynqmp_pm_probe’: drivers/soc/xilinx/zynqmp_power.c:193:12: error: ‘pm_api_version’ is used uninitialized [-Werror=uninitialized] 193 | if (pm_api_version < ZYNQMP_PM_VERSION) | ^ drivers/soc/xilinx/zynqmp_power.c:187:13: note: ‘pm_api_version’ was declared here 187 | u32 pm_api_version; | ^~~~~~~~~~~~~~ cc1: all warnings being treated as errors I think that this warning is bogus and gcc is wrong. But I don't know what to do with it :/ Anyway, it is un-realated to this patch. --- drivers/soc/xilinx/zynqmp_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/soc/xilinx/zynqmp_power.c b/drivers/soc/xilinx/zynqmp_power.c index 641dcc958911..62a7f6af9544 100644 --- a/drivers/soc/xilinx/zynqmp_power.c +++ b/drivers/soc/xilinx/zynqmp_power.c @@ -280,8 +280,7 @@ static int zynqmp_pm_remove(struct platform_device *pdev) if (event_registered) xlnx_unregister_event(PM_INIT_SUSPEND_CB, 0, 0, suspend_event_callback, NULL); - if (!rx_chan) - mbox_free_channel(rx_chan); + mbox_free_channel(rx_chan); return 0; }