gpio: fix gpio-device list corruption
authorJohan Hovold <johan@kernel.org>
Mon, 1 Mar 2021 09:05:19 +0000 (10:05 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Mon, 8 Mar 2021 10:59:17 +0000 (11:59 +0100)
commitcf25ef6b631c6fc6c0435fc91eba8734cca20511
treead48e36b8d0774a88eff34ddc44a2b5a42d3fcce
parenta6112998ee45514def58200a7914706c0703f3d7
gpio: fix gpio-device list corruption

Make sure to hold the gpio_lock when removing the gpio device from the
gpio_devices list (when dropping the last reference) to avoid corrupting
the list when there are concurrent accesses.

Fixes: ff2b13592299 ("gpio: make the gpiochip a real device")
Cc: stable@vger.kernel.org # 4.6
Reviewed-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpio/gpiolib.c