Commit 1adc90c7 authored by Aditya Pakki's avatar Aditya Pakki Committed by Linus Walleij

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: default avatarAditya Pakki <pakki001@umn.edu>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 182e80ee
...@@ -366,6 +366,8 @@ static int axp20x_build_funcs_groups(struct platform_device *pdev) ...@@ -366,6 +366,8 @@ static int axp20x_build_funcs_groups(struct platform_device *pdev)
pctl->funcs[i].groups = devm_kcalloc(&pdev->dev, pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
npins, sizeof(char *), npins, sizeof(char *),
GFP_KERNEL); GFP_KERNEL);
if (!pctl->funcs[i].groups)
return -ENOMEM;
for (pin = 0; pin < npins; pin++) for (pin = 0; pin < npins; pin++)
pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment