gpiolib: don't call sleeping functions with a spinlock taken
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 17 Apr 2020 07:01:51 +0000 (09:01 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 23 Apr 2020 15:55:27 +0000 (17:55 +0200)
commit6409d049ce28bef35e13dfb8699fc7ee27469ba1
tree4d5fc17f31d6c8e1906f7534260169a8936e8354
parent4e1541593017d76cfa04bd666de8e4dbcfe3105d
gpiolib: don't call sleeping functions with a spinlock taken

We must not call pinctrl_gpio_can_use_line() with the gpio_lock taken
as it takes a mutex internally. Let's move the call before taking the
spinlock and store the return value.

This isn't perfect - there's a moment between calling
pinctrl_gpio_can_use_line() and taking the spinlock where the situation
can change but it isn't a regression either: previously this part wasn't
protected at all and it only affects the information user-space is
seeing.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: d2ac25798208 ("gpiolib: provide a dedicated function for setting lineinfo")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c