pinctrl: sunxi: Testing the wrong variable
Subsystems (4)
PATCH 1/1 pinctrl: sunxi: Testing the wrong variable
Smatch complains that we dereference "map" before testing it for NULL which is true. We should be testing "*map" instead. Also on the error path, we should free *map and set it to NULL.
Signed-off-by Dan Carpenter <[email protected]>
drivers/pinctrl/sunxi/pinctrl-sunxi.c +3 -2
@@ -398,13 +398,14 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,* map array */ *map =krealloc (*map, i *sizeof (struct pinctrl_map ),GFP_KERNEL ); -if (!map) +if (!*map)return -ENOMEM ;return 0 ; err_free_map: -kfree (map); +kfree (*map); + *map =NULL ;return ret; }
Quoted 5 lines · Dan Carpenter
Smatch complains that we dereference "map" before testing it for NULL which is true. We should be testing "*map" instead. Also on the error path, we should free *map and set it to NULL.
Signed-off-by Dan Carpenter <[email protected]>
Acked-by Maxime Ripard <[email protected]>
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Quoted 5 lines · Dan Carpenter
Smatch complains that we dereference "map" before testing it for NULL which is true. We should be testing "*map" instead. Also on the error path, we should free *map and set it to NULL.
Signed-off-by Dan Carpenter <[email protected]>
Patch applied with Maxime's ACK.
Yours,
Linus Walleij