Skip to content

Commit 05214b0

Browse files
ColinIanKinglinusw
authored andcommitted
pinctrl: th1520: Fix potential null pointer dereference on func
The initialization of muxtype deferences pointer func before func is sanity checked with a null pointer check, hence we have a null pointer deference issue. Fix this by only deferencing func with the assignment to muxtype after func has been null pointer checked. Fixes: 1fc30cd ("pinctrl: th1520: Factor out casts") Signed-off-by: Colin Ian King <[email protected]> Reported-by: Kees Bakker <[email protected]> Acked-by: Drew Fustini <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 22c9182 commit 05214b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/pinctrl/pinctrl-th1520.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,12 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
803803
{
804804
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
805805
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
806-
enum th1520_muxtype muxtype = (uintptr_t)func->data;
806+
enum th1520_muxtype muxtype;
807807

808808
if (!func)
809809
return -EINVAL;
810810

811+
muxtype = (uintptr_t)func->data;
811812
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
812813
th1520_pad_muxdata(thp->desc.pins[gsel].drv_data),
813814
muxtype);

0 commit comments

Comments
 (0)