]> git.itanic.dy.fi Git - linux-stable/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>
Wed, 25 Oct 2023 09:16:34 +0000 (11:16 +0200)
commit0a33a61e25867a2b7e171d9b1af9984fad6fcf69
treef3c0d1ed7aa179b125ba849a0ad897cc5e610f8a
parent987fb4353c3bcfdc80e960419eee70e824cdde2c
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