From patchwork Thu Mar 10 06:33:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 12775971 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 370F7C433EF for ; Thu, 10 Mar 2022 06:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239875AbiCJGmh (ORCPT ); Thu, 10 Mar 2022 01:42:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231231AbiCJGmg (ORCPT ); Thu, 10 Mar 2022 01:42:36 -0500 X-Greylist: delayed 477 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 09 Mar 2022 22:41:35 PST Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD14DE33B3 for ; Wed, 9 Mar 2022 22:41:35 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowAAHDtq5myligd_CAg--.6137S2; Thu, 10 Mar 2022 14:33:31 +0800 (CST) From: Jiasheng Jiang To: hminas@synopsys.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] usb: dwc2: Add missing check for dwc2_vbus_supply_init Date: Thu, 10 Mar 2022 14:33:28 +0800 Message-Id: <20220310063328.1581166-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowAAHDtq5myligd_CAg--.6137S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr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ailing-List: linux-usb@vger.kernel.org As the potential failure of the dwc2_vbus_supply_init(), it should be better to handle the return value and check it. Fixes: cd7cd0e6cedf ("usb: dwc2: fix unbalanced use of external vbus-supply") Signed-off-by: Jiasheng Jiang Acked-by: Minas Harutyunyan --- drivers/usb/dwc2/hcd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index f63a27d11fac..c8786d223dcd 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3672,7 +3672,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, hprt0 |= HPRT0_PWR; dwc2_writel(hsotg, hprt0, HPRT0); if (!pwr) - dwc2_vbus_supply_init(hsotg); + retval = dwc2_vbus_supply_init(hsotg); break; case USB_PORT_FEAT_RESET: @@ -3722,7 +3722,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, "In host mode, hprt0=%08x\n", hprt0); dwc2_writel(hsotg, hprt0, HPRT0); if (!pwr) - dwc2_vbus_supply_init(hsotg); + retval = dwc2_vbus_supply_init(hsotg); } /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */ @@ -4523,7 +4523,9 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) /* Enable external vbus supply after resuming the port. */ spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_vbus_supply_init(hsotg); + ret = dwc2_vbus_supply_init(hsotg); + if (ret) + return ret; /* Wait for controller to correctly update D+/D- level */ usleep_range(3000, 5000);