Received: by 10.213.65.68 with SMTP id h4csp600819imn; Thu, 22 Mar 2018 04:43:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELvT4ziELDk27K1MIJ21NbiflCvfpn3F9uXUhlMw4IQ32Lyefdetu7rvEB1sk8myXerD0/Il X-Received: by 10.98.138.66 with SMTP id y63mr20134801pfd.12.1521718993444; Thu, 22 Mar 2018 04:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521718993; cv=none; d=google.com; s=arc-20160816; b=ILVQKL2FiIMbdcTWn3fI7qNmN0T2xGecQaFjDEn9LE0DvNragoBuWUDP4RrYuvKrzq iCBiJYacvWzQPivT0D0VsRKPl3oJh4Ez5gqmryT/ZU91dkU8YNQ3QMkMaF2+rme8HSLu FuQ7JZI9PbKuMl+KtDsX/nyHhM8WRH5Lzyqp5OmdR8Yldf/dx7PLPHYOPhNeijLsqeNx MwzhJKoQymPJsIeWX2aaRi6tkw3amzYJ4Xy/EnKakKjyvuYBzgXsyNkbONaPh+aho0DO ruQFsv0XcubDSKLY7JbWqO1jCjTdgEbOx8Of9F71AFzS4ykGNKYxFvOs2+SuV5SXBXXD ExtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=k4BRjSccNorvxcZO00/wD2jxx7TsTvbcHF3CnO2Ikn4=; b=AnzCaGZdUWsyfY95C3RauEgX44GsKr0g4IfufxHooVMf/WcfqXtdpl6DT7Bv2sQ+gk 1KZDlTesy4/gxC417H6LRXoD5GyVZeK+ozEk1W3tPcWW3VTCSk1BA1jv9X3avMHe3ksm L/WA3jMYpPx7EYE8J9t9VaXPNVrQcgqOiuoprtuHK+Bctt5sV5G/dpnbnSgMcA4/0j0v /raZRcL8etr4mEES1ZieDGfMlOVcTPbOyRyLTW1aXm7LZU457Da8lay6MD9MoADpZiDD 28o8YylMDFrc010VHhg+bHrOVJ4NMwsMohL9MK/Ot4aWgGKVdtyyrpWWjci5YlxD61vd FF+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h126si4235886pgc.817.2018.03.22.04.42.58; Thu, 22 Mar 2018 04:43:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbeCVLlv convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Mar 2018 07:41:51 -0400 Received: from gloria.sntech.de ([95.129.55.99]:55480 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbeCVLlu (ORCPT ); Thu, 22 Mar 2018 07:41:50 -0400 Received: from ip9234b5ec.dynamic.kabel-deutschland.de ([146.52.181.236] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1eyybD-0001jf-3M; Thu, 22 Mar 2018 12:41:39 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Tomeu Vizoso Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Amelie Delaunay , Minas Harutyunyan , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [PATCH] usb: dwc2: dwc2_vbus_supply_init: fix error check Date: Thu, 22 Mar 2018 12:41:38 +0100 Message-ID: <3806387.a3O5bOALIr@diego> In-Reply-To: <1711886.RiDBCvOSMq@diego> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <1711886.RiDBCvOSMq@diego> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomeu, Am Donnerstag, 22. M?rz 2018, 12:39:13 CET schrieb Heiko St?bner: > Am Donnerstag, 22. M?rz 2018, 10:39:43 CET schrieb Tomeu Vizoso: > > devm_regulator_get_optional returns -ENODEV if the regulator isn't > > there, so if that's the case we have to make sure not to leave -ENODEV > > in the regulator pointer. > > > > Also, make sure we return 0 in that case, but correctly propagate any > > other errors. Also propagate the error from _dwc2_hcd_start. > > > > Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus > > supply") Cc: Amelie Delaunay > > Signed-off-by: Tomeu Vizoso > > Thanks for catching that oops in your tests. > Reviewed-by: Heiko Stuebner I take that back :-) see below > > --- > > > > drivers/usb/dwc2/hcd.c | 13 ++++++++----- > > 1 file changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > > index dcfda5eb4cac..4ae211f65e85 100644 > > --- a/drivers/usb/dwc2/hcd.c > > +++ b/drivers/usb/dwc2/hcd.c > > @@ -359,8 +359,13 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg > > *hsotg) static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg) > > > > { > > > > hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); > > > > - if (IS_ERR(hsotg->vbus_supply)) > > - return 0; > > + if (IS_ERR(hsotg->vbus_supply)) { > > + hsotg->vbus_supply = NULL; > > + if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) hsotg->vbus_supply is already NULL here