From patchwork Wed Aug 3 06:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12935217 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 0C25FC19F28 for ; Wed, 3 Aug 2022 06:02:43 +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=8e9CmVO2YYLH0yGI5EfuNG2/uUmVyh2o8AsedIMi0aw=; b=vvyTIWLganWI9f iUrECj1MFAlZP0fKPnaZu/w57GgIRwObxrpcx+ze3rt2XiycQkpBHveZllS19muLJhnPOJpEw1IIf L86L2b9B0kZ11ScvWkcBV5sIoJ05MyAGXB/mqEkwV09hsexKBi+gVGph8HXzYCOFrSoBzqie3Zb8o 6UHt/6zcKFYYSqc41mYhNlgfRsgaQz3ntzw8vr9wjUgdU8UU6opaDIH4SPipDtqaIDDJ4Z0qo/SWw fK2seVxI5NLNYpx54zhBGVynj5D890XmUIkvRIx13P3t/Wm+iVDkuyYA8/vMXRFpjEYQySTzU5czU dtFAsH7hwavyAfwrrssQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJ7RZ-002w9I-0S; Wed, 03 Aug 2022 06:01:21 +0000 Received: from smtp09.smtpout.orange.fr ([80.12.242.131] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJ7RP-002w0G-3J for linux-arm-kernel@lists.infradead.org; Wed, 03 Aug 2022 06:01:15 +0000 Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id J7R0oDBQPnnjOJ7R0oabzZ; Wed, 03 Aug 2022 08:00:52 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 03 Aug 2022 08:00:52 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Sascha Hauer , Heikki Krogerus , Marek Vasut , Igor Grinberg , Felipe Balbi Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: pxa: Fix a memory leak in pxa310_otg_exit() Date: Wed, 3 Aug 2022 08:00:44 +0200 Message-Id: <890e3e7329b020356206262e9c3ee57378648e1c.1659506415.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-20220802_230113_137344_CBBF1558 X-CRM114-Status: GOOD ( 12.24 ) 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 When otg_ulpi_create() is called, 2 kzalloc() are performed. Only one is freed in pxa310_otg_exit(). The second kzalloc() has been introduced in the commit in the Fixes: tag. Add the missing kfree(). Fixes: 298b083cf9dd ("usb: otg: ulpi: Start using struct usb_otg") Signed-off-by: Christophe JAILLET --- This patch is NOT compile tested (I never cross compile even if I've been tolled many times that it was easy...) Another solution is to use devm_otg_ulpi_create() and further simplify arch/arm/mach-pxa/pxa3xx-ulpi.c. This would remove the only caller of otg_ulpi_create() and could also simplify drivers/usb/phy/phy-ulpi.[ch] --- arch/arm/mach-pxa/pxa3xx-ulpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c index c29a7f0fa1b0..82b4e2706f86 100644 --- a/arch/arm/mach-pxa/pxa3xx-ulpi.c +++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c @@ -229,6 +229,7 @@ static int pxa310_otg_init(struct pxa3xx_u2d_platform_data *pdata) static void pxa310_otg_exit(void) { + kfree(u2d->otg->otg); kfree(u2d->otg); } #else