Skip to content

Commit

Permalink
usb: ohci-da8xx: ensure error return on variable error is set
Browse files Browse the repository at this point in the history
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: d193abf ("usb: ohci-da8xx: add vbus and overcurrent gpios")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20200107123901.101190-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Colin Ian King authored and Greg Kroah-Hartman committed Jan 8, 2020
1 parent 96a0c12 commit ba9b408
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/usb/host/ohci-da8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit ba9b408

Please sign in to comment.