* [PATCH] gpio: add a check for the return value of ida_simple_get fails
@ 2019-03-09 4:07 Kangjie Lu
2019-03-11 9:31 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-09 4:07 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel
ida_simple_get may fail and return a negative error number.
The fix checks its return value; if it fails, go to err_destroy.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/gpio/gpio-exar.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index 0ecd2369c2ca..a09d2f9ebacc 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev)
mutex_init(&exar_gpio->lock);
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
+ if (index < 0)
+ goto err_destroy;
sprintf(exar_gpio->name, "exar_gpio%d", index);
exar_gpio->gpio_chip.label = exar_gpio->name;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: add a check for the return value of ida_simple_get fails
2019-03-09 4:07 [PATCH] gpio: add a check for the return value of ida_simple_get fails Kangjie Lu
@ 2019-03-11 9:31 ` Bartosz Golaszewski
0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2019-03-11 9:31 UTC (permalink / raw)
To: Kangjie Lu; +Cc: pakki001, Linus Walleij, linux-gpio, LKML
sob., 9 mar 2019 o 05:08 Kangjie Lu <kjlu@umn.edu> napisał(a):
>
> ida_simple_get may fail and return a negative error number.
> The fix checks its return value; if it fails, go to err_destroy.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/gpio/gpio-exar.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index 0ecd2369c2ca..a09d2f9ebacc 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev)
> mutex_init(&exar_gpio->lock);
>
> index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
> + if (index < 0)
> + goto err_destroy;
>
> sprintf(exar_gpio->name, "exar_gpio%d", index);
> exar_gpio->gpio_chip.label = exar_gpio->name;
> --
> 2.17.1
>
Applied, I Cc'ed stable and will send it to Linus Walleij once
v5.1-rc1 is tagged.
Bart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-11 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09 4:07 [PATCH] gpio: add a check for the return value of ida_simple_get fails Kangjie Lu
2019-03-11 9:31 ` Bartosz Golaszewski
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).