summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-08 22:07:57 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-03 06:26:27 +0200
commitb26f7e86d3cc0e8744cf198118e313911f20f1f6 (patch)
tree1e1144535ceb1873fcd3ae91c740716b8584ca26
parentdf74e70ffec6757f9ea75e7d1ea35de29c7d8b1a (diff)
downloadlinux-stable-b26f7e86d3cc0e8744cf198118e313911f20f1f6.tar.gz
linux-stable-b26f7e86d3cc0e8744cf198118e313911f20f1f6.tar.bz2
linux-stable-b26f7e86d3cc0e8744cf198118e313911f20f1f6.zip
gpio: exar: add a check for the return value of ida_simple_get fails
commit 7ecced0934e574b528a1ba6c237731e682216a74 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/gpio/gpio-exar.c2
1 files changed, 2 insertions, 0 deletions
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;