summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorAditya Pakki <pakki001@umn.edu>2019-03-12 16:19:10 +0100
committerLinus Walleij <linus.walleij@linaro.org>2019-04-08 11:20:28 +0200
commit1adc90c7395742827d754a5f02f446818a77c379 (patch)
tree2ac966b861fa728af9844d7ba9537ce60e24482b /drivers/pinctrl
parentgpiolib: devprop: Fix syntax error (diff)
downloadlinux-1adc90c7395742827d754a5f02f446818a77c379.tar.xz
linux-1adc90c7395742827d754a5f02f446818a77c379.zip
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>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-axp209.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index afd0b533c40a..4fcf7262bed9 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -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;
}