kernel: move console loglevel to generic
[oweals/openwrt.git] / target / linux / sunxi / patches-4.9 / 0042-pinctrl-sunxi-Testing-the-wrong-variable.patch
1 From b3cde198b17f504643cc1eeffc4623f03326f436 Mon Sep 17 00:00:00 2001
2 From: Dan Carpenter <dan.carpenter@oracle.com>
3 Date: Fri, 18 Nov 2016 14:35:57 +0300
4 Subject: pinctrl: sunxi: Testing the wrong variable
5
6 Smatch complains that we dereference "map" before testing it for NULL
7 which is true.  We should be testing "*map" instead.  Also on the error
8 path, we should free *map and set it to NULL.
9
10 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
11 Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
12 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
13 ---
14  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 5 +++--
15  1 file changed, 3 insertions(+), 2 deletions(-)
16
17 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
18 +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
19 @@ -398,13 +398,14 @@ static int sunxi_pctrl_dt_node_to_map(st
20          * map array
21          */
22         *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL);
23 -       if (!map)
24 +       if (!*map)
25                 return -ENOMEM;
26  
27         return 0;
28  
29  err_free_map:
30 -       kfree(map);
31 +       kfree(*map);
32 +       *map = NULL;
33         return ret;
34  }
35