From: Dan Carpenter Date: Fri, 18 Nov 2016 11:35:57 +0000 (+0300) Subject: pinctrl: sunxi: Testing the wrong variable X-Git-Tag: v4.10-rc1~168^2~20 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=b3cde198b17f504643cc1eeffc4623f03326f436;p=linux.git 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 Acked-by: Maxime Ripard Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 6b7953da4228..0eb51e33cb1b 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -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; }