Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dan.carpenter@oracle.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Dan Carpenter and committed by
Linus Walleij
b3cde198 04d02c7a

+3 -2
+3 -2
drivers/pinctrl/sunxi/pinctrl-sunxi.c
··· 398 398 * map array 399 399 */ 400 400 *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL); 401 - if (!map) 401 + if (!*map) 402 402 return -ENOMEM; 403 403 404 404 return 0; 405 405 406 406 err_free_map: 407 - kfree(map); 407 + kfree(*map); 408 + *map = NULL; 408 409 return ret; 409 410 } 410 411