Skip to content

Commit a05543d

Browse files
author
Bartosz Golaszewski
committed
gpio: it87: balance superio enter/exit calls in error path
We always call superio_enter() in it87_gpio_direction_out() but only call superio_exit() if the call to it87_gpio_set() succeeds. Move the label to balance the calls in error path as well. Fixes: ef877a1 ("gpio: it87: use new line value setter callbacks") Reported-by: Daniel Gibson <daniel@gibson.sh> Closes: https://lore.kernel.org/all/bd0a00e3-9b8c-43e8-8772-e67b91f4c71e@gibson.sh/ Link: https://lore.kernel.org/r/20251210055026.23146-1-bartosz.golaszewski@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 8f0b4cc commit a05543d

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

drivers/gpio/gpio-it87.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1414

15+
#include <linux/cleanup.h>
1516
#include <linux/init.h>
1617
#include <linux/kernel.h>
1718
#include <linux/module.h>
@@ -241,23 +242,17 @@ static int it87_gpio_direction_out(struct gpio_chip *chip,
241242
mask = 1 << (gpio_num % 8);
242243
group = (gpio_num / 8);
243244

244-
spin_lock(&it87_gpio->lock);
245+
guard(spinlock)(&it87_gpio->lock);
245246

246247
rc = superio_enter();
247248
if (rc)
248-
goto exit;
249+
return rc;
249250

250251
/* set the output enable bit */
251252
superio_set_mask(mask, group + it87_gpio->output_base);
252253

253254
rc = it87_gpio_set(chip, gpio_num, val);
254-
if (rc)
255-
goto exit;
256-
257255
superio_exit();
258-
259-
exit:
260-
spin_unlock(&it87_gpio->lock);
261256
return rc;
262257
}
263258

0 commit comments

Comments
 (0)