* [PATCH 1/2] pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails
@ 2012-06-09 12:01 Devendra Naga
2012-06-12 11:31 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Devendra Naga @ 2012-06-09 12:01 UTC (permalink / raw)
To: Linus Walleij, linux-kernel; +Cc: Devendra Naga
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.
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
drivers/pinctrl/pinctrl-mxs.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c
index 556e45a..9d46303 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;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails
2012-06-09 12:01 [PATCH 1/2] pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails Devendra Naga
@ 2012-06-12 11:31 ` Linus Walleij
2012-06-12 11:50 ` Dong Aisheng
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2012-06-12 11:31 UTC (permalink / raw)
To: Devendra Naga, Dong Aisheng, Shawn Guo; +Cc: linux-kernel
On Sat, Jun 9, 2012 at 2:01 PM, Devendra Naga <devendra.aaru@gmail.com> wrote:
> 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.
>
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Obviously correct so applied.
Dong, Shawn: any ACKs?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails
2012-06-12 11:31 ` Linus Walleij
@ 2012-06-12 11:50 ` Dong Aisheng
0 siblings, 0 replies; 3+ messages in thread
From: Dong Aisheng @ 2012-06-12 11:50 UTC (permalink / raw)
To: Linus Walleij; +Cc: Devendra Naga, Dong Aisheng, Shawn Guo, linux-kernel
On Tue, Jun 12, 2012 at 01:31:25PM +0200, Linus Walleij wrote:
> On Sat, Jun 9, 2012 at 2:01 PM, Devendra Naga <devendra.aaru@gmail.com> wrote:
>
> > 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.
> >
> > Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
>
> Obviously correct so applied.
>
> Dong, Shawn: any ACKs?
>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Regards
Dong Aisheng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-12 11:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-09 12:01 [PATCH 1/2] pinctrl: pinctrl-mxs: Take care of frees if the kzalloc fails Devendra Naga
2012-06-12 11:31 ` Linus Walleij
2012-06-12 11:50 ` Dong Aisheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox