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

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: ef877a159072 ("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>

+3 -8
+3 -8
drivers/gpio/gpio-it87.c
··· 12 12 13 13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14 14 15 + #include <linux/cleanup.h> 15 16 #include <linux/init.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/module.h> ··· 242 241 mask = 1 << (gpio_num % 8); 243 242 group = (gpio_num / 8); 244 243 245 - spin_lock(&it87_gpio->lock); 244 + guard(spinlock)(&it87_gpio->lock); 246 245 247 246 rc = superio_enter(); 248 247 if (rc) 249 - goto exit; 248 + return rc; 250 249 251 250 /* set the output enable bit */ 252 251 superio_set_mask(mask, group + it87_gpio->output_base); 253 252 254 253 rc = it87_gpio_set(chip, gpio_num, val); 255 - if (rc) 256 - goto exit; 257 - 258 254 superio_exit(); 259 - 260 - exit: 261 - spin_unlock(&it87_gpio->lock); 262 255 return rc; 263 256 } 264 257