public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mfd: mc13xxx-core: Initialize the lock prior to using it
@ 2014-04-15 22:56 Fabio Estevam
  2014-04-16  9:15 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2014-04-15 22:56 UTC (permalink / raw)
  To: sameo; +Cc: lee.jones, linux, linux-kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

After request_threaded_irq() is called there is a chance that an interrupt
may occur before the 'mc13xxx->lock' is initialized, which will trigger a kernel
oops.

In order to prevent that, move the initialization of 'mc13xxx->lock' prior to
requesting the interrupts.

Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Changed kernel warning --> kernel oops to better describe the problem
- Added Russell's Ack

 drivers/mfd/mc13xxx-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 06e64b6..9e296c4 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -660,13 +660,13 @@ int mc13xxx_common_init(struct device *dev)
 	if (ret)
 		return ret;
 
+	mutex_init(&mc13xxx->lock);
+
 	ret = request_threaded_irq(mc13xxx->irq, NULL, mc13xxx_irq_thread,
 			IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx);
 	if (ret)
 		return ret;
 
-	mutex_init(&mc13xxx->lock);
-
 	if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata)
 		mc13xxx->flags = pdata->flags;
 
-- 
1.8.3.2


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

* Re: [PATCH v2] mfd: mc13xxx-core: Initialize the lock prior to using it
  2014-04-15 22:56 [PATCH v2] mfd: mc13xxx-core: Initialize the lock prior to using it Fabio Estevam
@ 2014-04-16  9:15 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2014-04-16  9:15 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: sameo, linux, linux-kernel, Fabio Estevam

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> After request_threaded_irq() is called there is a chance that an interrupt
> may occur before the 'mc13xxx->lock' is initialized, which will trigger a kernel
> oops.
> 
> In order to prevent that, move the initialization of 'mc13xxx->lock' prior to
> requesting the interrupts.
> 
> Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Changed kernel warning --> kernel oops to better describe the problem
> - Added Russell's Ack

No you didn't. ;)

Applied with Russell's Ack.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2014-04-16  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-15 22:56 [PATCH v2] mfd: mc13xxx-core: Initialize the lock prior to using it Fabio Estevam
2014-04-16  9:15 ` Lee Jones

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