]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
pinctrl: sunxi: Testing the wrong variable
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 18 Nov 2016 11:35:57 +0000 (14:35 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 22 Nov 2016 08:55:33 +0000 (09:55 +0100)
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>
drivers/pinctrl/sunxi/pinctrl-sunxi.c

index 6b7953da4228f12471051c2502e59c270599b3e6..0eb51e33cb1be5412ab11d10e7cdb474a2faa061 100644 (file)
@@ -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;
 }