public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 1/2] mfd: max77693: Remove unused iolock mutex
@ 2012-06-08  0:34 Axel Lin
  2012-06-08  0:35 ` [PATCH 2/2] mfd: max77693: fix irq leak and wrong kfree call Axel Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2012-06-08  0:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Chanwoo Choi, Myungjoo Ham, Kyungmin Park, Samuel Ortiz

Now this driver is using regmap API, the iolock mutex is not used and can be
removed.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mfd/max77693.c               |    2 --
 include/linux/mfd/max77693-private.h |    1 -
 2 files changed, 3 deletions(-)

diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index e9e4278..4055bc2 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -138,8 +138,6 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 
 	max77693->wakeup = pdata->wakeup;
 
-	mutex_init(&max77693->iolock);
-
 	if (max77693_read_reg(max77693->regmap,
 				MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
 		dev_err(max77693->dev, "device not found on this channel\n");
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h
index 68263c5..1eeae5c 100644
--- a/include/linux/mfd/max77693-private.h
+++ b/include/linux/mfd/max77693-private.h
@@ -190,7 +190,6 @@ struct max77693_dev {
 	struct i2c_client *i2c;		/* 0xCC , PMIC, Charger, Flash LED */
 	struct i2c_client *muic;	/* 0x4A , MUIC */
 	struct i2c_client *haptic;	/* 0x90 , Haptic */
-	struct mutex iolock;
 
 	int type;
 
-- 
1.7.9.5




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

* [PATCH 2/2] mfd: max77693: fix irq leak and wrong kfree call
  2012-06-08  0:34 [PATCH RESEND 1/2] mfd: max77693: Remove unused iolock mutex Axel Lin
@ 2012-06-08  0:35 ` Axel Lin
  2012-06-29 16:26   ` Samuel Ortiz
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2012-06-08  0:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Chanwoo Choi, Myungjoo Ham, Kyungmin Park, Samuel Ortiz

We need to call max77693_irq_exit() in max77693_i2c_probe error patch and
max77693_i2c_remove.

Current code already uses devm_kzalloc() to allocate memory for max77693.
Thus we should not call kfree(max77693), otherwise we got double free.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mfd/max77693.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index 4055bc2..4251757 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -122,7 +122,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
 	if (IS_ERR(max77693->regmap)) {
 		ret = PTR_ERR(max77693->regmap);
-		dev_err(max77693->dev,"failed to allocate register map: %d\n",
+		dev_err(max77693->dev, "failed to allocate register map: %d\n",
 				ret);
 		goto err_regmap;
 	}
@@ -154,7 +154,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 
 	ret = max77693_irq_init(max77693);
 	if (ret < 0)
-		goto err_mfd;
+		goto err_irq;
 
 	pm_runtime_set_active(max77693->dev);
 
@@ -168,11 +168,11 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 	return ret;
 
 err_mfd:
+	max77693_irq_exit(max77693);
+err_irq:
 	i2c_unregister_device(max77693->muic);
 	i2c_unregister_device(max77693->haptic);
 err_regmap:
-	kfree(max77693);
-
 	return ret;
 }
 
@@ -181,6 +181,7 @@ static int max77693_i2c_remove(struct i2c_client *i2c)
 	struct max77693_dev *max77693 = i2c_get_clientdata(i2c);
 
 	mfd_remove_devices(max77693->dev);
+	max77693_irq_exit(max77693);
 	i2c_unregister_device(max77693->muic);
 	i2c_unregister_device(max77693->haptic);
 
-- 
1.7.9.5




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

* Re: [PATCH 2/2] mfd: max77693: fix irq leak and wrong kfree call
  2012-06-08  0:35 ` [PATCH 2/2] mfd: max77693: fix irq leak and wrong kfree call Axel Lin
@ 2012-06-29 16:26   ` Samuel Ortiz
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Ortiz @ 2012-06-29 16:26 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Chanwoo Choi, Myungjoo Ham, Kyungmin Park

Hi Axel,

On Fri, Jun 08, 2012 at 08:35:37AM +0800, Axel Lin wrote:
> We need to call max77693_irq_exit() in max77693_i2c_probe error patch and
> max77693_i2c_remove.
> 
> Current code already uses devm_kzalloc() to allocate memory for max77693.
> Thus we should not call kfree(max77693), otherwise we got double free.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/mfd/max77693.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
> index 4055bc2..4251757 100644
> --- a/drivers/mfd/max77693.c
> +++ b/drivers/mfd/max77693.c
> @@ -122,7 +122,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
>  	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
>  	if (IS_ERR(max77693->regmap)) {
>  		ret = PTR_ERR(max77693->regmap);
> -		dev_err(max77693->dev,"failed to allocate register map: %d\n",
> +		dev_err(max77693->dev, "failed to allocate register map: %d\n",
>  				ret);
>  		goto err_regmap;
>  	}
This is an unrelated change. I applied this patch except for this chunk.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2012-06-29 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-08  0:34 [PATCH RESEND 1/2] mfd: max77693: Remove unused iolock mutex Axel Lin
2012-06-08  0:35 ` [PATCH 2/2] mfd: max77693: fix irq leak and wrong kfree call Axel Lin
2012-06-29 16:26   ` Samuel Ortiz

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