* [PATCH v2 2/2] gpio: fix gpio-device list corruption [not found] <20210301090519.26192-1-johan@kernel.org> @ 2021-03-01 9:05 ` Johan Hovold 2021-03-02 15:41 ` Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Johan Hovold @ 2021-03-01 9:05 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski Cc: Greg Kroah-Hartman, Saravana Kannan, linux-gpio, linux-kernel, Johan Hovold, stable 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> --- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 6e0572515d02..4253837f870b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -475,8 +475,12 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_valid); static void gpiodevice_release(struct device *dev) { struct gpio_device *gdev = container_of(dev, struct gpio_device, dev); + unsigned long flags; + spin_lock_irqsave(&gpio_lock, flags); list_del(&gdev->list); + spin_unlock_irqrestore(&gpio_lock, flags); + ida_free(&gpio_ida, gdev->id); kfree_const(gdev->label); kfree(gdev->descs); -- 2.26.2 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 2/2] gpio: fix gpio-device list corruption 2021-03-01 9:05 ` [PATCH v2 2/2] gpio: fix gpio-device list corruption Johan Hovold @ 2021-03-02 15:41 ` Linus Walleij 0 siblings, 0 replies; 2+ messages in thread From: Linus Walleij @ 2021-03-02 15:41 UTC (permalink / raw) To: Johan Hovold Cc: Bartosz Golaszewski, Greg Kroah-Hartman, Saravana Kannan, open list:GPIO SUBSYSTEM, linux-kernel, stable On Mon, Mar 1, 2021 at 10:05 AM Johan Hovold <johan@kernel.org> wrote: > 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> Excellent fix as well, Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-03 0:48 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210301090519.26192-1-johan@kernel.org> 2021-03-01 9:05 ` [PATCH v2 2/2] gpio: fix gpio-device list corruption Johan Hovold 2021-03-02 15:41 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).