From: Aditya Pakki Date: Tue, 12 Mar 2019 15:19:10 +0000 (-0500) Subject: pinctrl: axp209: Fix NULL pointer dereference after allocation X-Git-Tag: v5.2-rc1~129^2~27 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=1adc90c7395742827d754a5f02f446818a77c379;p=linux.git 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 Signed-off-by: Linus Walleij --- 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; }