Message ID | 20221118104332.943-1-korotkov.maxim.s@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | pinctrl: single: fix potential NULL dereference | expand |
* Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]: > Added checking of pointer "function" in pcs_set_mux(). > pinmux_generic_get_function() can return NULL and the pointer > "function" was dereferenced without checking against NULL. Reviewed-by: Tony Lindgren <tony@atomide.com>
Dear Linus, Will this patch be applied or rejected? best regards, Max On 18.11.2022 15:52, Tony Lindgren wrote: > * Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]: >> Added checking of pointer "function" in pcs_set_mux(). >> pinmux_generic_get_function() can return NULL and the pointer >> "function" was dereferenced without checking against NULL. > > Reviewed-by: Tony Lindgren <tony@atomide.com>
On Fri, Nov 18, 2022 at 11:43 AM Maxim Korotkov <korotkov.maxim.s@gmail.com> wrote: > Added checking of pointer "function" in pcs_set_mux(). > pinmux_generic_get_function() can return NULL and the pointer > "function" was dereferenced without checking against NULL. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions") > Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com> Patch applied for fixes. Yours, Linus Walleij
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 67bec7ea0f8b..5655a2da5413 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -372,6 +372,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector, if (!pcs->fmask) return 0; function = pinmux_generic_get_function(pctldev, fselector); + if (!function) + return -EINVAL; func = function->data; if (!func) return -EINVAL;
Added checking of pointer "function" in pcs_set_mux(). pinmux_generic_get_function() can return NULL and the pointer "function" was dereferenced without checking against NULL. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions") Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com> --- drivers/pinctrl/pinctrl-single.c | 2 ++ 1 file changed, 2 insertions(+)