public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: ad5398 - fix a memory leak
@ 2010-09-01  2:29 Axel Lin
  2010-09-01  2:56 ` Zhang, Sonic
  2010-09-01  9:15 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2010-09-01  2:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, Sonic Zhang

In current implementation, the address return from regulator_register()
is different from the address for regulator_unregister().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/ad5398.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index 15ff61d..a4be416 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -25,7 +25,7 @@ struct ad5398_chip_info {
 	unsigned int current_level;
 	unsigned int current_mask;
 	unsigned int current_offset;
-	struct regulator_dev rdev;
+	struct regulator_dev *rdev;
 };
 
 static int ad5398_calc_current(struct ad5398_chip_info *chip,
@@ -211,7 +211,6 @@ MODULE_DEVICE_TABLE(i2c, ad5398_id);
 static int __devinit ad5398_probe(struct i2c_client *client,
 				const struct i2c_device_id *id)
 {
-	struct regulator_dev *rdev;
 	struct regulator_init_data *init_data = client->dev.platform_data;
 	struct ad5398_chip_info *chip;
 	const struct ad5398_current_data_format *df =
@@ -233,9 +232,10 @@ static int __devinit ad5398_probe(struct i2c_client *client,
 	chip->current_offset = df->current_offset;
 	chip->current_mask = (chip->current_level - 1) << chip->current_offset;
 
-	rdev = regulator_register(&ad5398_reg, &client->dev, init_data, chip);
-	if (IS_ERR(rdev)) {
-		ret = PTR_ERR(rdev);
+	chip->rdev = regulator_register(&ad5398_reg, &client->dev,
+					init_data, chip);
+	if (IS_ERR(chip->rdev)) {
+		ret = PTR_ERR(chip->rdev);
 		dev_err(&client->dev, "failed to register %s %s\n",
 			id->name, ad5398_reg.name);
 		goto err;
@@ -254,7 +254,7 @@ static int __devexit ad5398_remove(struct i2c_client *client)
 {
 	struct ad5398_chip_info *chip = i2c_get_clientdata(client);
 
-	regulator_unregister(&chip->rdev);
+	regulator_unregister(chip->rdev);
 	kfree(chip);
 
 	return 0;
-- 
1.7.2




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

* RE: [PATCH] regulator: ad5398 - fix a memory leak
  2010-09-01  2:29 [PATCH] regulator: ad5398 - fix a memory leak Axel Lin
@ 2010-09-01  2:56 ` Zhang, Sonic
  2010-09-01  9:15 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Zhang, Sonic @ 2010-09-01  2:56 UTC (permalink / raw)
  To: Axel Lin, linux-kernel; +Cc: Liam Girdwood, Mark Brown

 

>-----Original Message-----
>From: Axel Lin [mailto:axel.lin@gmail.com] 
>Sent: Wednesday, September 01, 2010 10:29 AM
>To: linux-kernel
>Cc: Liam Girdwood; Mark Brown; Zhang, Sonic
>Subject: [PATCH] regulator: ad5398 - fix a memory leak
>
>In current implementation, the address return from 
>regulator_register() is different from the address for 
>regulator_unregister().
>

Acked-by: Sonic Zhang <sonic.zhang@analog.com>

>Signed-off-by: Axel Lin <axel.lin@gmail.com>
>---
> drivers/regulator/ad5398.c |   12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/regulator/ad5398.c 
>b/drivers/regulator/ad5398.c index 15ff61d..a4be416 100644
>--- a/drivers/regulator/ad5398.c
>+++ b/drivers/regulator/ad5398.c
>@@ -25,7 +25,7 @@ struct ad5398_chip_info {
> 	unsigned int current_level;
> 	unsigned int current_mask;
> 	unsigned int current_offset;
>-	struct regulator_dev rdev;
>+	struct regulator_dev *rdev;
> };
> 
> static int ad5398_calc_current(struct ad5398_chip_info *chip, 
>@@ -211,7 +211,6 @@ MODULE_DEVICE_TABLE(i2c, ad5398_id);  
>static int __devinit ad5398_probe(struct i2c_client *client,
> 				const struct i2c_device_id *id)
> {
>-	struct regulator_dev *rdev;
> 	struct regulator_init_data *init_data = 
>client->dev.platform_data;
> 	struct ad5398_chip_info *chip;
> 	const struct ad5398_current_data_format *df = @@ -233,9 
>+232,10 @@ static int __devinit ad5398_probe(struct i2c_client *client,
> 	chip->current_offset = df->current_offset;
> 	chip->current_mask = (chip->current_level - 1) << 
>chip->current_offset;
> 
>-	rdev = regulator_register(&ad5398_reg, &client->dev, 
>init_data, chip);
>-	if (IS_ERR(rdev)) {
>-		ret = PTR_ERR(rdev);
>+	chip->rdev = regulator_register(&ad5398_reg, &client->dev,
>+					init_data, chip);
>+	if (IS_ERR(chip->rdev)) {
>+		ret = PTR_ERR(chip->rdev);
> 		dev_err(&client->dev, "failed to register %s %s\n",
> 			id->name, ad5398_reg.name);
> 		goto err;
>@@ -254,7 +254,7 @@ static int __devexit ad5398_remove(struct 
>i2c_client *client)  {
> 	struct ad5398_chip_info *chip = i2c_get_clientdata(client);
> 
>-	regulator_unregister(&chip->rdev);
>+	regulator_unregister(chip->rdev);
> 	kfree(chip);
> 
> 	return 0;
>--
>1.7.2
>
>
>
>

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

* Re: [PATCH] regulator: ad5398 - fix a memory leak
  2010-09-01  2:29 [PATCH] regulator: ad5398 - fix a memory leak Axel Lin
  2010-09-01  2:56 ` Zhang, Sonic
@ 2010-09-01  9:15 ` Mark Brown
  2010-09-01 11:54   ` Liam Girdwood
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2010-09-01  9:15 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Sonic Zhang

On Wed, Sep 01, 2010 at 10:29:18AM +0800, Axel Lin wrote:
> In current implementation, the address return from regulator_register()
> is different from the address for regulator_unregister().
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

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

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

* Re: [PATCH] regulator: ad5398 - fix a memory leak
  2010-09-01  9:15 ` Mark Brown
@ 2010-09-01 11:54   ` Liam Girdwood
  0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-09-01 11:54 UTC (permalink / raw)
  To: Mark Brown; +Cc: Axel Lin, linux-kernel, Sonic Zhang

On Wed, 2010-09-01 at 10:15 +0100, Mark Brown wrote:
> On Wed, Sep 01, 2010 at 10:29:18AM +0800, Axel Lin wrote:
> > In current implementation, the address return from regulator_register()
> > is different from the address for regulator_unregister().
> > 
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Applied.

Thanks

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


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

end of thread, other threads:[~2010-09-01 11:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-01  2:29 [PATCH] regulator: ad5398 - fix a memory leak Axel Lin
2010-09-01  2:56 ` Zhang, Sonic
2010-09-01  9:15 ` Mark Brown
2010-09-01 11:54   ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox