summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorWilliam Dean <williamsukatube@gmail.com>2022-07-10 23:48:22 +0800
committerLinus Walleij <linus.walleij@linaro.org>2022-07-11 15:04:19 +0200
commitacf50233fc979b566e3b87d329191dcd01e2a72c (patch)
tree22eac9b15e92f93221215acdd4f073845c5ec867 /drivers/pinctrl
parentc3b821e8e406d5650e587b7ac624ac24e9b780a8 (diff)
downloadlinux-stable-acf50233fc979b566e3b87d329191dcd01e2a72c.tar.gz
linux-stable-acf50233fc979b566e3b87d329191dcd01e2a72c.tar.bz2
linux-stable-acf50233fc979b566e3b87d329191dcd01e2a72c.zip
pinctrl: sunplus: Add check for kcalloc
As the potential failure of the kcalloc(), it should be better to check it in order to avoid the dereference of the NULL pointer. Fixes: aa74c44be19c8 ("pinctrl: Add driver for Sunplus SP7021") Reported-by: Hacash Robot <hacashRobot@santino.com> Signed-off-by: William Dean <williamsukatube@gmail.com> Link: https://lore.kernel.org/r/20220710154822.2610801-1-williamsukatube@163.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/sunplus/sppctl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index 3ba47040ac42..2b3335ab56c6 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -871,6 +871,9 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
}
*map = kcalloc(*num_maps + nmG, sizeof(**map), GFP_KERNEL);
+ if (*map == NULL)
+ return -ENOMEM;
+
for (i = 0; i < (*num_maps); i++) {
dt_pin = be32_to_cpu(list[i]);
pin_num = FIELD_GET(GENMASK(31, 24), dt_pin);