Skip to content

Commit 333830a

Browse files
tiwaibrgl
authored andcommitted
gpio: exar: Fix bad handling for ida_simple_get error path
The commit 7ecced0 ("gpio: exar: add a check for the return value of ida_simple_get fails") added a goto jump to the common error handler for ida_simple_get() error, but this is wrong in two ways: it doesn't set the proper return code and, more badly, it invokes ida_simple_remove() with a negative index that shall lead to a kernel panic via BUG_ON(). This patch addresses those two issues. Fixes: 7ecced0 ("gpio: exar: add a check for the return value of ida_simple_get fails") Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 19c26d9 commit 333830a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/gpio/gpio-exar.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
148148
mutex_init(&exar_gpio->lock);
149149

150150
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
151-
if (index < 0)
152-
goto err_destroy;
151+
if (index < 0) {
152+
ret = index;
153+
goto err_mutex_destroy;
154+
}
153155

154156
sprintf(exar_gpio->name, "exar_gpio%d", index);
155157
exar_gpio->gpio_chip.label = exar_gpio->name;
@@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
176178

177179
err_destroy:
178180
ida_simple_remove(&ida_index, index);
181+
err_mutex_destroy:
179182
mutex_destroy(&exar_gpio->lock);
180183
return ret;
181184
}

0 commit comments

Comments
 (0)