All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove
@ 2010-04-19  1:58 Axel Lin
  2010-04-19 12:34 ` Liam Girdwood
  2010-04-19 17:01 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Axel Lin @ 2010-04-19  1:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sascha Hauer, Liam Girdwood, Mark Brown, Samuel Ortiz

This patch fixes a memory leak by freeing priv in mc13783_regulator_remove

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/regulator/mc13783-regulator.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/mc13783-regulator.c
b/drivers/regulator/mc13783-regulator.c
index a681f5e..ad036dd 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -618,9 +618,12 @@ static int __devexit
mc13783_regulator_remove(struct platform_device *pdev)
                dev_get_platdata(&pdev->dev);
        int i;

+       platform_set_drvdata(pdev, NULL);
+
        for (i = 0; i < pdata->num_regulators; i++)
                regulator_unregister(priv->regulators[i]);

+       kfree(priv);
        return 0;
 }

-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove
  2010-04-19  1:58 [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove Axel Lin
@ 2010-04-19 12:34 ` Liam Girdwood
  2010-04-19 17:01 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-04-19 12:34 UTC (permalink / raw)
  To: axel.lin; +Cc: linux-kernel, Sascha Hauer, Mark Brown, Samuel Ortiz

On Mon, 2010-04-19 at 09:58 +0800, Axel Lin wrote:
> This patch fixes a memory leak by freeing priv in mc13783_regulator_remove
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Liam Girdwood <lrg@slimlogic.co.uk>
> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  drivers/regulator/mc13783-regulator.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 

Applied.

Thanks

Liam

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove
  2010-04-19  1:58 [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove Axel Lin
  2010-04-19 12:34 ` Liam Girdwood
@ 2010-04-19 17:01 ` Mark Brown
  2010-04-20  5:34   ` Axel Lin
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2010-04-19 17:01 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Sascha Hauer, Liam Girdwood, Samuel Ortiz

On Mon, Apr 19, 2010 at 09:58:02AM +0800, Axel Lin wrote:
> This patch fixes a memory leak by freeing priv in mc13783_regulator_remove

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

but note that...

> +       platform_set_drvdata(pdev, NULL);
> +

This is completely unrelated to what your description says (and is not
needed).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mc13783-regulator: fix a memory leak in  mc13783_regulator_remove
  2010-04-19 17:01 ` Mark Brown
@ 2010-04-20  5:34   ` Axel Lin
  2010-04-20 16:32     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Axel Lin @ 2010-04-20  5:34 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Sascha Hauer, Liam Girdwood, Samuel Ortiz

hi Mark,

2010/4/20 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On Mon, Apr 19, 2010 at 09:58:02AM +0800, Axel Lin wrote:
>> This patch fixes a memory leak by freeing priv in mc13783_regulator_remove
>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
>
> but note that...
>
>> +       platform_set_drvdata(pdev, NULL);
>> +
>
> This is completely unrelated to what your description says (and is not
> needed).
>

In the probe function , the driver uses platform_set_drvdata(pdev,
priv) to store a pointer to the priv data structure.
To avoid leaving a dangling pointer behind, the driver should clear
the pointer to priv before freeing priv.

Regards,
Axel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove
  2010-04-20  5:34   ` Axel Lin
@ 2010-04-20 16:32     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-04-20 16:32 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Sascha Hauer, Liam Girdwood, Samuel Ortiz

On Tue, Apr 20, 2010 at 01:34:18PM +0800, Axel Lin wrote:
> 2010/4/20 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> > On Mon, Apr 19, 2010 at 09:58:02AM +0800, Axel Lin wrote:

> >> +       platform_set_drvdata(pdev, NULL);
> >> +

> > This is completely unrelated to what your description says (and is not
> > needed).

> In the probe function , the driver uses platform_set_drvdata(pdev,
> priv) to store a pointer to the priv data structure.
> To avoid leaving a dangling pointer behind, the driver should clear
> the pointer to priv before freeing priv.

All of which is totally unrelated to the description of the patch.  One
of the things that I do when I'm reviewing is look to see if the patch
does what the description says - unrelated changes are normally a red
flag that something is wrong and there are mistakes or unintended side
effects lurking in the code.

The dangling pointer isn't really a problem in any case; if a driver
is relying on the behaviour of the pointer between bindings it's in
trouble anyway since there aren't any guarantees about what happens.
See the recent discussion about the same issue for I2C.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-20 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19  1:58 [PATCH] mc13783-regulator: fix a memory leak in mc13783_regulator_remove Axel Lin
2010-04-19 12:34 ` Liam Girdwood
2010-04-19 17:01 ` Mark Brown
2010-04-20  5:34   ` Axel Lin
2010-04-20 16:32     ` Mark Brown

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.