Skip to content

Commit acf5023

Browse files
William Deanlinusw
authored andcommitted
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: aa74c44 ("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>
1 parent c3b821e commit acf5023

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pinctrl/sunplus/sppctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,9 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
871871
}
872872

873873
*map = kcalloc(*num_maps + nmG, sizeof(**map), GFP_KERNEL);
874+
if (*map == NULL)
875+
return -ENOMEM;
876+
874877
for (i = 0; i < (*num_maps); i++) {
875878
dt_pin = be32_to_cpu(list[i]);
876879
pin_num = FIELD_GET(GENMASK(31, 24), dt_pin);

0 commit comments

Comments
 (0)