Skip to content

Commit

Permalink
pinctrl: axp209: Fix NULL pointer dereference after allocation
Browse files Browse the repository at this point in the history
axp20x_build_funcs_groups allocates groups via devm_kcalloc and tries to
dereference without checking for NULL. This patch avoids such a
scenario.

Signed-off-by: Aditya Pakki <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
Aditya Pakki authored and linusw committed Apr 8, 2019
1 parent 182e80e commit 1adc90c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/pinctrl/pinctrl-axp209.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ static int axp20x_build_funcs_groups(struct platform_device *pdev)
pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
npins, sizeof(char *),
GFP_KERNEL);
if (!pctl->funcs[i].groups)
return -ENOMEM;
for (pin = 0; pin < npins; pin++)
pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
}
Expand Down

0 comments on commit 1adc90c

Please sign in to comment.