Skip to content

Commit

Permalink
pinctrl: ralink: Check for null return of devm_kcalloc
Browse files Browse the repository at this point in the history
[ Upstream commit c3b821e ]

Because of the possible failure of the allocation, data->domains might
be NULL pointer and will cause the dereference of the NULL pointer
later.
Therefore, it might be better to check it and directly return -ENOMEM
without releasing data manually if fails, because the comment of the
devm_kmalloc() says "Memory allocated with this function is
automatically freed on driver detach.".

Fixes: a86854d ("treewide: devm_kzalloc() -> devm_kcalloc()")
Reported-by: Hacash Robot <hacashRobot@santino.com>
Signed-off-by: William Dean <williamsukatube@gmail.com>
Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@163.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
William Dean authored and gregkh committed Jul 29, 2022
1 parent a67eb28 commit 5595d30
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/pinctrl/ralink/pinctrl-ralink.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ static int ralink_pinmux_pins(struct ralink_priv *p)
p->func[i]->pin_count,
sizeof(int),
GFP_KERNEL);
if (!p->func[i]->pins)
return -ENOMEM;
for (j = 0; j < p->func[i]->pin_count; j++)
p->func[i]->pins[j] = p->func[i]->pin_first + j;

Expand Down

0 comments on commit 5595d30

Please sign in to comment.