[PATCH] [23/98] mmc: sdhci: Check mrq != NULL in sdhci_tasklet_finish

Andi Kleen
2011-07-27T00:38:52Z

From: Chris Ball <cjb@laptop.org>

commit 0c9c99a765321104cc5f9c97f949382a9ba4927e upstream.

It seems that under certain circumstances the sdhci_tasklet_finish()
call can be entered with mrq set to NULL, causing the system to crash
with a NULL pointer de-reference.

Seen on S3C6410 system. Based on a patch by Dimitris Papastamos.

Reported-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
drivers/mmc/host/sdhci.c | 7 +++++++
1 file changed, 7 insertions(+)

Index: linux-2.6.35.y/drivers/mmc/host/sdhci.c
===================================================================
--- linux-2.6.35.y.orig/drivers/mmc/host/sdhci.c
+++ linux-2.6.35.y/drivers/mmc/host/sdhci.c
@@ -1278,6 +1278,13 @@ static void sdhci_tasklet_finish(unsigne

host = (struct sdhci_host*)param;

+ /*
+ * If this tasklet gets rescheduled while running, it will
+ * be run again afterwards but without any active request.
+ */
+ if (!host->mrq)
+ return;
+
spin_lock_irqsave(&host->lock, flags);

del_timer(&host->timer);