[PATCH v7 01/16] pinctrl: check the return value of pinmux_ops::get_function_name()
Andy Shevchenko
andriy.shevchenko at intel.com
Tue Sep 2 06:06:23 PDT 2025
On Tue, Sep 02, 2025 at 01:59:10PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
>
> While the API contract in docs doesn't specify it explicitly,
So, why not to amend the doc at the same time?
> 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.
Fixes?
Reported?
Closes?
...
> while (selector < nfuncs) {
> const char *fname = ops->get_function_name(pctldev, selector);
>
> - if (!strcmp(function, fname))
> + if (fname && !strcmp(function, fname))
> return selector;
I would slightly refactor this:
const char *fname;
fname = ops->get_function_name(pctldev, selector);
if (fname && !strcmp(function, fname))
return selector;
> selector++;
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list