Skip to content

Commit d01240b

Browse files
clf700383Linus Walleij
authored andcommitted
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 <[email protected]> Reviewed-by: Drew Fustini <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 06783dc commit d01240b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/pinctrl/pinctrl-th1520.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
798798
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
799799
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
800800

801+
if (!func)
802+
return -EINVAL;
801803
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
802804
(uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA,
803805
(uintptr_t)func->data);

0 commit comments

Comments
 (0)