Commit acf50233 authored by William Dean's avatar William Dean Committed by Linus Walleij

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: aa74c44b ("pinctrl: Add driver for Sunplus SP7021")
Reported-by: default avatarHacash Robot <hacashRobot@santino.com>
Signed-off-by: default avatarWilliam Dean <williamsukatube@gmail.com>
Link: https://lore.kernel.org/r/20220710154822.2610801-1-williamsukatube@163.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent c3b821e8
......@@ -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);
......
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