diff options
author | Devendra Naga <devendra.aaru@gmail.com> | 2012-06-09 14:01:23 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-06-12 16:25:56 +0200 |
commit | 0bf7481852c8ece4888c299ba0259b789c3dbde3 (patch) | |
tree | 7595ae92e141a7fa822a701192c63698cae0921a /drivers/pinctrl | |
parent | pinctrl: pinctrl-imx: fix incorrect debug message of maps (diff) | |
download | linux-0bf7481852c8ece4888c299ba0259b789c3dbde3.tar.xz linux-0bf7481852c8ece4888c299ba0259b789c3dbde3.zip |
pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails
if there is no purecfg , the group pointer is allocated using kzalloc and if it
fails to allocate, we wont free the new_map,
if config is true, we call kmemdup and if it
fails to do so we wont free the allocated group if there is no purecfg.
fix this by doing the frees of new_map pointer and group pointers.
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-mxs.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c index 556e45a213eb..9d46303a84e7 100644 --- a/drivers/pinctrl/pinctrl-mxs.c +++ b/drivers/pinctrl/pinctrl-mxs.c @@ -107,8 +107,10 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev, /* Compose group name */ group = kzalloc(length, GFP_KERNEL); - if (!group) - return -ENOMEM; + if (!group) { + ret = -ENOMEM; + goto free; + } snprintf(group, length, "%s.%d", np->name, reg); new_map[i].data.mux.group = group; i++; @@ -118,7 +120,7 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev, pconfig = kmemdup(&config, sizeof(config), GFP_KERNEL); if (!pconfig) { ret = -ENOMEM; - goto free; + goto free_group; } new_map[i].type = PIN_MAP_TYPE_CONFIGS_GROUP; @@ -133,6 +135,9 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev, return 0; +free_group: + if (!purecfg) + free(group); free: kfree(new_map); return ret; |