]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
pinctrl: avoid unsafe code pattern in find_pinctrl()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 20 Sep 2023 18:09:10 +0000 (11:09 -0700)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 25 Sep 2023 13:29:26 +0000 (15:29 +0200)
commitc153a4edff6ab01370fcac8e46f9c89cca1060c2
tree168e8a4030c9a649143f4fce5ec889c300d80c9b
parent64061b67335e958e6328bcb5bb2b5490d57f3f59
pinctrl: avoid unsafe code pattern in find_pinctrl()

The code in find_pinctrl() takes a mutex and traverses a list of pinctrl
structures. Later the caller bumps up reference count on the found
structure. Such pattern is not safe as pinctrl that was found may get
deleted before the caller gets around to increasing the reference count.

Fix this by taking the reference count in find_pinctrl(), while it still
holds the mutex.

Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/ZQs1RgTKg6VJqmPs@google.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/core.c