From patchwork Tue Apr 18 09:07:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Yang X-Patchwork-Id: 675564 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 4960FC77B75 for ; Tue, 18 Apr 2023 09:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbjDRJJR (ORCPT ); Tue, 18 Apr 2023 05:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjDRJJB (ORCPT ); Tue, 18 Apr 2023 05:09:01 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56D617A85; Tue, 18 Apr 2023 02:08:40 -0700 (PDT) Received: from legion.. ([172.16.0.254]) (user=lidaxian@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33I98CGR017477-33I98CGS017477 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Apr 2023 17:08:18 +0800 From: Li Yang To: Greg Kroah-Hartman , Felipe Balbi , Sergey Shtylyov Cc: Li Yang , Dongliang Mu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() Date: Tue, 18 Apr 2023 17:07:57 +0800 Message-Id: <20230418090758.18756-1-lidaxian@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-FEAS-AUTH-USER: lidaxian@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. 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); + goto err_remove_phy; + } ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt, IRQF_ONESHOT, "tahvo-vbus", tu);