pinctrl: pinctrl-imx: free if of_get_parent fails to get the parent node
authorDevendra Naga <devendra.aaru@gmail.com>
Thu, 7 Jun 2012 16:49:26 +0000 (22:19 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 12 Jun 2012 11:35:32 +0000 (13:35 +0200)
of_get_parent can return null if no parent node found, so the allocated new_map
should be freed.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-imx.c

index 09f3a30..542b01b 100644 (file)
@@ -173,8 +173,10 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 
        /* create mux map */
        parent = of_get_parent(np);
-       if (!parent)
+       if (!parent) {
+               kfree(new_map);
                return -EINVAL;
+       }
        new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
        new_map[0].data.mux.function = parent->name;
        new_map[0].data.mux.group = np->name;