Skip to contentSkip to conversation

gpio: add a check for the return value of ida_simple_get fails

PATCH Applied Kangjie Lu 2 participants 2 messages Mar 9, 2019 – Mar 11, 2019 GPIO

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 gpio: add a check for the return value of ida_simple_get fails

ida_simple_get may fail and return a negative error number. The fix checks its return value; if it fails, go to err_destroy.

---
 drivers/gpio/gpio-exar.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-exar.c +2 -0
index 0ecd2369c2ca..a09d2f9ebacc 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw

sob., 9 mar 2019 o 05:08 Kangjie Lu <[email protected]> napisał(a):

Quoted 23 lines

ida_simple_get may fail and return a negative error number. The fix checks its return value; if it fails, go to err_destroy.

---
 drivers/gpio/gpio-exar.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-exar.c +2 -1
index 0ecd2369c2ca..a09d2f9ebacc 100644
@@ -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;
--
Quoted 2 lines

2.17.1

Applied, I Cc'ed stable and will send it to Linus Walleij once v5.1-rc1 is tagged.

Bart