Skip to content

Commit c3b821e

Browse files
William Deanlinusw
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 <[email protected]> Signed-off-by: William Dean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 3234649 commit c3b821e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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)