* [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
@ 2011-07-02 19:21 Jesper Juhl
2011-07-04 17:33 ` Samuel Ortiz
0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-07-02 19:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Graeme Gregory, Jorge Eduardo Candelaria, Samuel Ortiz
There are a couple of situations where we leak init_data in
drivers/mfd/tps65910.c:tps65910_i2c_probe() - this patch should take
care of them.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
drivers/mfd/tps65910.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
Compile tested only.
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 2229e66..0db62f4 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -144,15 +144,17 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
return -EINVAL;
init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL);
- if (init_data == NULL)
+ if (!init_data)
return -ENOMEM;
init_data->irq = pmic_plat_data->irq;
init_data->irq_base = pmic_plat_data->irq;
tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL);
- if (tps65910 == NULL)
+ if (!tps65910) {
+ kfree(init_data);
return -ENOMEM;
+ }
i2c_set_clientdata(i2c, tps65910);
tps65910->dev = &i2c->dev;
@@ -174,11 +176,13 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
if (ret < 0)
goto err;
+ kfree(init_data);
return ret;
err:
mfd_remove_devices(tps65910->dev);
kfree(tps65910);
+ kfree(init_data);
return ret;
}
--
1.7.6
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
2011-07-02 19:21 [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe Jesper Juhl
@ 2011-07-04 17:33 ` Samuel Ortiz
2011-07-05 7:46 ` Jesper Juhl
0 siblings, 1 reply; 6+ messages in thread
From: Samuel Ortiz @ 2011-07-04 17:33 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel, Graeme Gregory, Jorge Eduardo Candelaria
Hi Jesper,
On Sat, Jul 02, 2011 at 09:21:38PM +0200, Jesper Juhl wrote:
> There are a couple of situations where we leak init_data in
> drivers/mfd/tps65910.c:tps65910_i2c_probe() - this patch should take
> care of them.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> drivers/mfd/tps65910.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> Compile tested only.
>
> diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
> index 2229e66..0db62f4 100644
> --- a/drivers/mfd/tps65910.c
> +++ b/drivers/mfd/tps65910.c
> @@ -144,15 +144,17 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> return -EINVAL;
>
> init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL);
> - if (init_data == NULL)
> + if (!init_data)
This is not a memory leak fix. And I actually prefer the == NULL check.
Please remove the == NULL check replacement with !* and keep only the memory
leak fixing part.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
2011-07-04 17:33 ` Samuel Ortiz
@ 2011-07-05 7:46 ` Jesper Juhl
2011-07-05 22:29 ` Jesper Juhl
0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-07-05 7:46 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: linux-kernel, Graeme Gregory, Jorge Eduardo Candelaria
On Mon, 4 Jul 2011, Samuel Ortiz wrote:
> Hi Jesper,
>
> On Sat, Jul 02, 2011 at 09:21:38PM +0200, Jesper Juhl wrote:
> > There are a couple of situations where we leak init_data in
> > drivers/mfd/tps65910.c:tps65910_i2c_probe() - this patch should take
> > care of them.
> >
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> > drivers/mfd/tps65910.c | 8 ++++++--
> > 1 files changed, 6 insertions(+), 2 deletions(-)
> >
> > Compile tested only.
> >
> > diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
> > index 2229e66..0db62f4 100644
> > --- a/drivers/mfd/tps65910.c
> > +++ b/drivers/mfd/tps65910.c
> > @@ -144,15 +144,17 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> > return -EINVAL;
> >
> > init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL);
> > - if (init_data == NULL)
> > + if (!init_data)
> This is not a memory leak fix. And I actually prefer the == NULL check.
> Please remove the == NULL check replacement with !* and keep only the memory
> leak fixing part.
>
Fair enough. Guess I just made that change out of habit. I'll respin it
later and send a new patch.
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
2011-07-05 7:46 ` Jesper Juhl
@ 2011-07-05 22:29 ` Jesper Juhl
2011-07-05 22:54 ` Graeme Gregory
2011-07-06 18:34 ` Samuel Ortiz
0 siblings, 2 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-07-05 22:29 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: linux-kernel, Graeme Gregory, Jorge Eduardo Candelaria
On Tue, 5 Jul 2011, Jesper Juhl wrote:
> On Mon, 4 Jul 2011, Samuel Ortiz wrote:
>
[...]
> > This is not a memory leak fix. And I actually prefer the == NULL check.
> > Please remove the == NULL check replacement with !* and keep only the memory
> > leak fixing part.
> >
Here's an updated patch.
From: Jesper Juhl <jj@chaosbits.net>
Subject: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
There are a couple of situations where we leak init_data in
drivers/mfd/tps65910.c:tps65910_i2c_probe() - this patch should take
care of them.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
drivers/mfd/tps65910.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 2229e66..7a3eb2d 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -151,8 +151,10 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
init_data->irq_base = pmic_plat_data->irq;
tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL);
- if (tps65910 == NULL)
+ if (tps65910 == NULL) {
+ kfree(init_data);
return -ENOMEM;
+ }
i2c_set_clientdata(i2c, tps65910);
tps65910->dev = &i2c->dev;
@@ -174,11 +176,13 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
if (ret < 0)
goto err;
+ kfree(init_data);
return ret;
err:
mfd_remove_devices(tps65910->dev);
kfree(tps65910);
+ kfree(init_data);
return ret;
}
--
1.7.6
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
2011-07-05 22:29 ` Jesper Juhl
@ 2011-07-05 22:54 ` Graeme Gregory
2011-07-06 18:34 ` Samuel Ortiz
1 sibling, 0 replies; 6+ messages in thread
From: Graeme Gregory @ 2011-07-05 22:54 UTC (permalink / raw)
To: Jesper Juhl; +Cc: Samuel Ortiz, linux-kernel, Jorge Eduardo Candelaria
On 07/05/2011 11:29 PM, Jesper Juhl wrote:
> On Tue, 5 Jul 2011, Jesper Juhl wrote:
>
>> On Mon, 4 Jul 2011, Samuel Ortiz wrote:
>>
> [...]
>>> This is not a memory leak fix. And I actually prefer the == NULL check.
>>> Please remove the == NULL check replacement with !* and keep only the memory
>>> leak fixing part.
>>>
> Here's an updated patch.
>
>
> From: Jesper Juhl <jj@chaosbits.net>
> Subject: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
>
> There are a couple of situations where we leak init_data in
> drivers/mfd/tps65910.c:tps65910_i2c_probe() - this patch should take
> care of them.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> drivers/mfd/tps65910.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
> index 2229e66..7a3eb2d 100644
> --- a/drivers/mfd/tps65910.c
> +++ b/drivers/mfd/tps65910.c
> @@ -151,8 +151,10 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> init_data->irq_base = pmic_plat_data->irq;
>
> tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL);
> - if (tps65910 == NULL)
> + if (tps65910 == NULL) {
> + kfree(init_data);
> return -ENOMEM;
> + }
>
> i2c_set_clientdata(i2c, tps65910);
> tps65910->dev = &i2c->dev;
> @@ -174,11 +176,13 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> if (ret < 0)
> goto err;
>
> + kfree(init_data);
> return ret;
>
> err:
> mfd_remove_devices(tps65910->dev);
> kfree(tps65910);
> + kfree(init_data);
> return ret;
> }
>
Sorry didnt reply to this first time round.
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe
2011-07-05 22:29 ` Jesper Juhl
2011-07-05 22:54 ` Graeme Gregory
@ 2011-07-06 18:34 ` Samuel Ortiz
1 sibling, 0 replies; 6+ messages in thread
From: Samuel Ortiz @ 2011-07-06 18:34 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel, Graeme Gregory, Jorge Eduardo Candelaria
Hi Jesper,
On Wed, Jul 06, 2011 at 12:29:07AM +0200, Jesper Juhl wrote:
> On Tue, 5 Jul 2011, Jesper Juhl wrote:
>
> > On Mon, 4 Jul 2011, Samuel Ortiz wrote:
> >
> [...]
> > > This is not a memory leak fix. And I actually prefer the == NULL check.
> > > Please remove the == NULL check replacement with !* and keep only the memory
> > > leak fixing part.
> > >
> Here's an updated patch.
Applied, thanks a lot.
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-07-06 18:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-02 19:21 [PATCH] mfd: Don't leak init_data in tps65910_i2c_probe Jesper Juhl
2011-07-04 17:33 ` Samuel Ortiz
2011-07-05 7:46 ` Jesper Juhl
2011-07-05 22:29 ` Jesper Juhl
2011-07-05 22:54 ` Graeme Gregory
2011-07-06 18:34 ` Samuel Ortiz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.