Skip to content

Commit c3b821e

Browse files
William DeanLinus Walleij
authored andcommitted
pinctrl: ralink: Check for null return of devm_kcalloc
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>
1 parent 3234649 commit c3b821e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/pinctrl/ralink/pinctrl-ralink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ static int ralink_pinctrl_pins(struct ralink_priv *p)
266266
p->func[i]->pin_count,
267267
sizeof(int),
268268
GFP_KERNEL);
269+
if (!p->func[i]->pins)
270+
return -ENOMEM;
269271
for (j = 0; j < p->func[i]->pin_count; j++)
270272
p->func[i]->pins[j] = p->func[i]->pin_first + j;
271273

0 commit comments

Comments
 (0)