From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E720C77B76 for ; Tue, 18 Apr 2023 11:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231289AbjDRLTm (ORCPT ); Tue, 18 Apr 2023 07:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjDRLTj (ORCPT ); Tue, 18 Apr 2023 07:19:39 -0400 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEDC24C29; Tue, 18 Apr 2023 04:19:05 -0700 (PDT) Received: from [192.168.1.103] (31.173.80.61) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.14; Tue, 18 Apr 2023 14:17:16 +0300 Subject: Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() To: Li Yang , Greg Kroah-Hartman , Felipe Balbi CC: Dongliang Mu , , References: <20230418090758.18756-1-lidaxian@hust.edu.cn> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <96c7edf5-e1cc-03f6-ee52-ef373ae9d820@omp.ru> Date: Tue, 18 Apr 2023 14:17:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20230418090758.18756-1-lidaxian@hust.edu.cn> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [31.173.80.61] X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.59, Database issued on: 04/18/2023 10:57:34 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 0 X-KSE-AntiSpam-Info: Lua profiles 176790 [Apr 18 2023] X-KSE-AntiSpam-Info: Version: 5.9.59.0 X-KSE-AntiSpam-Info: Envelope from: s.shtylyov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 509 509 b12bcaa7ba85624b485f2b6b92324b70964a1c65 X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: omp.ru:7.1.1;127.0.0.199:7.1.2;31.173.80.61:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: ApMailHostAddress: 31.173.80.61 X-KSE-AntiSpam-Info: Rate: 0 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=temperror header.from=omp.ru;spf=temperror smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 04/18/2023 11:00:00 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 4/18/2023 7:17:00 AM X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 4/18/23 12:07 PM, Li Yang wrote: > Smatch reports: > drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe() > warn: missing unwind goto? > > After geting irq, if ret < 0, it will return without error handling to > free memory. > Just add error handling to fix this problem. Oops, I'm sorry for missing that one... > Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check") > Signed-off-by: Li Yang > Reviewed-by: Dongliang Mu > --- > The issue is found by static analysis, and the patch remains untest. > --- > drivers/usb/phy/phy-tahvo.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c > index f2d2cc586c5b..184a5f3d7473 100644 > --- a/drivers/usb/phy/phy-tahvo.c > +++ b/drivers/usb/phy/phy-tahvo.c > @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev) > dev_set_drvdata(&pdev->dev, tu); > > tu->irq = ret = platform_get_irq(pdev, 0); > - if (ret < 0) > - return ret; > + if (ret < 0) { > + dev_err(&pdev->dev, "could not get irq: %d\n", > + ret); Adding the error message needs another patch, strictly speaking... > + goto err_remove_phy; > + } > ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt, > IRQF_ONESHOT, > "tahvo-vbus", tu); MBR, Sergey