Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: exar: 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.

Cc: <stable@vger.kernel.org>
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

authored by

Kangjie Lu and committed by
Bartosz Golaszewski
7ecced09 9e98c678

+2
+2
drivers/gpio/gpio-exar.c
··· 148 148 mutex_init(&exar_gpio->lock); 149 149 150 150 index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); 151 + if (index < 0) 152 + goto err_destroy; 151 153 152 154 sprintf(exar_gpio->name, "exar_gpio%d", index); 153 155 exar_gpio->gpio_chip.label = exar_gpio->name;