Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp608080ybl; Tue, 7 Jan 2020 11:48:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwgsi/TpCniIa1oCxCoNzBw0jEr5e6EXgVMX5CO7NCzWf38Af4WH3O+Nrggr7GpWtDXKIGX X-Received: by 2002:a9d:7984:: with SMTP id h4mr1408885otm.297.1578426528624; Tue, 07 Jan 2020 11:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578426528; cv=none; d=google.com; s=arc-20160816; b=wJLmtVtB3jrNjQcOdTkkX257yYcJDYK43ytpk/JlCJyUlzK0i6iiv8RnGqYofO39LQ wE8RcVLeqnNBcYtL+MVtcxcTu8KruT7DxIdS+yBf0mA0BvyijZpjMhig+NKRSxo6ggic JZq4si0HK7XRyzcTSVL4Jr4JeClsPMY4piAPN65QS7rSJvRnllFmbyfVmQnoAOzO9tQd zzywtBkyNZE8tGJT948Z+tKmmccJ6PoTRE1ZAGGHdBqlR7qoPcz6CSatcE6hj6bQi/p0 CjsElH+3ClBatCXWNG6679trGDn7QUdGHm1XpAps/XNXkIqYYe5SJpw7c1wbA1cTOgDR z1Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=aUxSGqgilBWM0Th2pF+wB5LFdlOAk3DVitqRxfKfYtU=; b=AO2D+/N5pHli6fhbnDwe+hkCtxllDTQoBu7nz3bu51req4QJKPp9bwFoPRMaK7FyB6 4+nq0B8YbEWG7XmIWExsZHt1U76wsvDkAEkTqn2x86fOC321NSEYyIS4D44/YeG5+Kw2 J5Ka9rpjUA2b5es5ljAFBQqCD9ZDn8GV4HtV1GO7tAV6Ue3AwYw2uMgRAKnv0adfQf0V Fa0nEX9vUaNnbPBvr3Xf9P2NrLX6Z7dK7bCcbkebpWf+hYvOkxRerteOQDjn4St+0yQe WTSDHWbVvsw1Yrs8qMOjS5ECC190OJa5p2vgxdlihcNWnRLxNjZ6qKDtIAHqw1j8Kno4 QX7w== 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 b4si550004oib.70.2020.01.07.11.48.35; Tue, 07 Jan 2020 11:48:48 -0800 (PST) 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 S1728624AbgAGTrp (ORCPT + 99 others); Tue, 7 Jan 2020 14:47:45 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:48232 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728421AbgAGTro (ORCPT ); Tue, 7 Jan 2020 14:47:44 -0500 Received: (qmail 7650 invoked by uid 2102); 7 Jan 2020 14:47:43 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Jan 2020 14:47:43 -0500 Date: Tue, 7 Jan 2020 14:47:43 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Colin King cc: Greg Kroah-Hartman , Sekhar Nori , Bartosz Golaszewski , , , Subject: Re: [PATCH][V3] usb: ohci-da8xx: ensure error return on variable error is set In-Reply-To: <20200107123901.101190-1-colin.king@canonical.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Jan 2020, Colin King wrote: > From: Colin Ian King > > Currently when an error occurs when calling devm_gpiod_get_optional or > calling gpiod_to_irq it causes an uninitialized error return in variable > 'error' to be returned. Fix this by ensuring the error variable is set > from da8xx_ohci->oc_gpio and oc_irq. > > Thanks to Dan Carpenter for spotting the uninitialized error in the > gpiod_to_irq failure case. > > Addresses-Coverity: ("Uninitialized scalar variable") > Fixes: d193abf1c913 ("usb: ohci-da8xx: add vbus and overcurrent gpios") > Signed-off-by: Colin Ian King > --- > > V2: fix typo and grammar in commit message > V3: fix gpiod_to_irq error case, re-write commit message > > --- > drivers/usb/host/ohci-da8xx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c > index 38183ac438c6..1371b0c249ec 100644 > --- a/drivers/usb/host/ohci-da8xx.c > +++ b/drivers/usb/host/ohci-da8xx.c > @@ -415,13 +415,17 @@ static int ohci_da8xx_probe(struct platform_device *pdev) > } > > da8xx_ohci->oc_gpio = devm_gpiod_get_optional(dev, "oc", GPIOD_IN); > - if (IS_ERR(da8xx_ohci->oc_gpio)) > + if (IS_ERR(da8xx_ohci->oc_gpio)) { > + error = PTR_ERR(da8xx_ohci->oc_gpio); > goto err; > + } > > if (da8xx_ohci->oc_gpio) { > oc_irq = gpiod_to_irq(da8xx_ohci->oc_gpio); > - if (oc_irq < 0) > + if (oc_irq < 0) { > + error = oc_irq; > goto err; > + } > > error = devm_request_threaded_irq(dev, oc_irq, NULL, > ohci_da8xx_oc_thread, IRQF_TRIGGER_RISING | Acked-by: Alan Stern