* [PATCH][V3] usb: ohci-da8xx: ensure error return on variable error is set
@ 2020-01-07 12:39 Colin King
2020-01-07 19:47 ` Alan Stern
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-01-07 12:39 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman, Sekhar Nori, Bartosz Golaszewski,
linux-usb
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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 <colin.king@canonical.com>
---
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 |
--
2.24.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][V3] usb: ohci-da8xx: ensure error return on variable error is set
2020-01-07 12:39 [PATCH][V3] usb: ohci-da8xx: ensure error return on variable error is set Colin King
@ 2020-01-07 19:47 ` Alan Stern
0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2020-01-07 19:47 UTC (permalink / raw)
To: Colin King
Cc: Greg Kroah-Hartman, Sekhar Nori, Bartosz Golaszewski, linux-usb,
kernel-janitors, linux-kernel
On Tue, 7 Jan 2020, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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 <colin.king@canonical.com>
> ---
>
> 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 <stern@rowland.harvard.edu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-07 19:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 12:39 [PATCH][V3] usb: ohci-da8xx: ensure error return on variable error is set Colin King
2020-01-07 19:47 ` Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).