]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Oct 2023 21:05:37 +0000 (23:05 +0200)
commit5a6ce81d7c16268bab312a6f44146fc8386e2e45
treeefc7285403510c03ec7f195f70236cd0af3fe14e
parent1c790191cab46069c18482f5a3b17ba2a59d81ae
pinctrl: avoid unsafe code pattern in find_pinctrl()

commit c153a4edff6ab01370fcac8e46f9c89cca1060c2 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pinctrl/core.c