diff options
| author | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2025-09-02 13:59:10 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-15 12:00:24 +0200 |
| commit | 688c688e0bf55824f4a38f8c2180046f089a3e3b (patch) | |
| tree | 774d634b29866fac22c8f4bdd2dc0709a405f365 | |
| parent | 9338093db954918558677a468d32e77041c65167 (diff) | |
| download | linux-688c688e0bf55824f4a38f8c2180046f089a3e3b.tar.gz linux-688c688e0bf55824f4a38f8c2180046f089a3e3b.tar.bz2 linux-688c688e0bf55824f4a38f8c2180046f089a3e3b.zip | |
pinctrl: check the return value of pinmux_ops::get_function_name()
commit 4002ee98c022d671ecc1e4a84029e9ae7d8a5603 upstream.
While the API contract in docs doesn't specify it explicitly, the
generic implementation of the get_function_name() callback from struct
pinmux_ops - pinmux_generic_get_function_name() - can fail and return
NULL. This is already checked in pinmux_check_ops() so add a similar
check in pinmux_func_name_to_selector() instead of passing the returned
pointer right down to strcmp() where the NULL can get dereferenced. This
is normal operation when adding new pinfunctions.
Cc: stable@vger.kernel.org
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/pinctrl/pinmux.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 2c31e7f2a27a..56e14193d678 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -337,7 +337,7 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev, while (selector < nfuncs) { const char *fname = ops->get_function_name(pctldev, selector); - if (!strcmp(function, fname)) + if (fname && !strcmp(function, fname)) return selector; selector++; |
