public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] misc: Fix irq leak in max8997_muic_probe error path
@ 2012-03-26  1:57 Axel Lin
  2012-03-26  8:17 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-03-26  1:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Donggeun Kim, MyungJoo Ham, Kyungmin Park, Arnd Bergmann,
	Greg Kroah-Hartman

Current code does not properly free allocated irqs if request_threaded_irq
returns error, fix it.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
---
This patch was sent on LKML:https://lkml.org/lkml/2011/12/17/114
This resend re-generate the patch because it does not apply due to
the change in commit 71e5878 "misc: Remove max8997-muic sysfs attributes".

 drivers/misc/max8997-muic.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/max8997-muic.c b/drivers/misc/max8997-muic.c
index 19591ea..2e7df9c 100644
--- a/drivers/misc/max8997-muic.c
+++ b/drivers/misc/max8997-muic.c
@@ -440,10 +440,6 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
 				"failed: irq request (IRQ: %d,"
 				" error :%d)\n",
 				muic_irq->irq, ret);
-
-			for (i = i - 1; i >= 0; i--)
-				free_irq(muic_irq->irq, info);
-
 			goto err_irq;
 		}
 	}
@@ -457,6 +453,8 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
 	return ret;
 
 err_irq:
+	while (--i >= 0)
+		free_irq(pdata->irq_base + muic_irqs[i].irq, info);
 err_pdata:
 	kfree(info);
 err_kfree:
-- 
1.7.5.4




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

* Re: [PATCH RESEND] misc: Fix irq leak in max8997_muic_probe error path
  2012-03-26  1:57 [PATCH RESEND] misc: Fix irq leak in max8997_muic_probe error path Axel Lin
@ 2012-03-26  8:17 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2012-03-26  8:17 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Donggeun Kim, MyungJoo Ham, Kyungmin Park,
	Greg Kroah-Hartman

On Monday 26 March 2012, Axel Lin wrote:
> 
> Current code does not properly free allocated irqs if request_threaded_irq
> returns error, fix it.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

It took me a while to see why this is correct.

Acked-by: Arnd Bergmann <arnd@arndb.de>

Note: It would be nicer to move the dev_err() down into the error path as well
and also fix the message to print the correct irq number, but your patch is
the important part.

Note to the driver maintainers: It looks like there is a race in the 
max8997_muic_irq_handler() function assigning the info->irq member
when multiple interrupts come in at the same time. Also, calling
sched_work from a threaded interrupt handler is pointless. I would suggest
fixing both of these by removing the work function and calling moving
its contents into the interrupt handler directly. Please correct me if I
am missing somehting here.

	Arnd


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

end of thread, other threads:[~2012-03-26  8:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-26  1:57 [PATCH RESEND] misc: Fix irq leak in max8997_muic_probe error path Axel Lin
2012-03-26  8:17 ` Arnd Bergmann

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