mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-28 16:53:49 +00:00
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: 1fc30cd927
("pinctrl: th1520: Factor out casts")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reported-by: Kees Bakker <kees@ijzerbout.nl>
Acked-by: Drew Fustini <dfustini@tenstorrent.com>
Link: https://lore.kernel.org/20241016155655.334518-1-colin.i.king@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
22c918258f
commit
05214b06ee
@ -803,11 +803,12 @@ 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);
|
||||
enum th1520_muxtype muxtype = (uintptr_t)func->data;
|
||||
enum th1520_muxtype muxtype;
|
||||
|
||||
if (!func)
|
||||
return -EINVAL;
|
||||
|
||||
muxtype = (uintptr_t)func->data;
|
||||
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
|
||||
th1520_pad_muxdata(thp->desc.pins[gsel].drv_data),
|
||||
muxtype);
|
||||
|
Loading…
Reference in New Issue
Block a user