pinctrl: thead1520: Fix Null pointer dereference

pinmux_generic_get_function may return NULL, and its retval is
dereferenced without check, which will cause a NULL pointer
dereference.

Signed-off-by: clingfei <clf700383@gmail.com>
Reviewed-by: Drew Fustini <dfustini@tenstorrent.com>
Link: https://lore.kernel.org/20241003023307.2138695-1-clf700383@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
clingfei 2024-10-03 10:33:07 +08:00 committed by Linus Walleij
parent 06783dc520
commit d01240b22a

View File

@ -798,6 +798,8 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
if (!func)
return -EINVAL;
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
(uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA,
(uintptr_t)func->data);