Commit 73f8ce7f authored by Wells Lu's avatar Wells Lu Committed by Linus Walleij
Browse files

pinctrl:sunplus: Add check for kmalloc



Fix Smatch static checker warning:
potential null dereference 'configs'. (kmalloc returns null)

Changes in v2:
1. Add free allocated memory before returned -ENOMEM.
2. Add call of_node_put() before returned -ENOMEM.

Fixes: aa74c44b ("pinctrl: Add driver for Sunplus SP7021")
Signed-off-by: default avatarWells Lu <wellslutw@gmail.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1685277277-12209-1-git-send-email-wellslutw@gmail.com


[Rebased on the patch from Lu Hongfei]
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent b2132afe
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -971,8 +971,7 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node

sppctl_map_err:
	for (i = 0; i < (*num_maps); i++)
		if (((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN) &&
		    (*map)[i].data.configs.configs)
		if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
			kfree((*map)[i].data.configs.configs);
	kfree(*map);
	of_node_put(parent);