1
0
Fork 0

pinctrl: axp209: Fix NULL pointer dereference after allocation

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 <pakki001@umn.edu>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
hifive-unleashed-5.2
Aditya Pakki 2019-03-12 10:19:10 -05:00 committed by Linus Walleij
parent 182e80eeaf
commit 1adc90c739
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}