[PATCH] mmc: core: Add sanity NULL pointer check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 762877485 "mmc: core: Handle card shutdown from mmc_bus"
added shutdown support. However, there are some situations where the
'owner' struct pointer can be NULL.

Solve this by adding a check, just as it's done in the other busses.

This commit solves a panic upon a reboot request, found in today's linux-next,
on a Armada 370 Mirabox board.

[snip]
[  225.592003] Unable to handle kernel NULL pointer dereference at virtual address 0000004c
[  225.600114] pgd = eea2c000
[  225.602897] [0000004c] *pgd=2ea38831, *pte=00000000, *ppte=00000000
[  225.609216] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
[  225.614628] CPU: 0 PID: 1100 Comm: init Not tainted 3.10.0-next-20130704 #19
[  225.621690] task: ef1adb00 ti: ef3ce000 task.ti: ef3ce000
[  225.627111] PC is at mmc_bus_shutdown+0x14/0x5c
[  225.631657] LR is at device_shutdown+0x34/0x184
[  225.636196] pc : [<c0267548>]    lr : [<c01b487c>]    psr: 600f0013
[  225.636196] sp : ef3cfe68  ip : 00000002  fp : 00000000
[  225.647693] r10: 00000000  r9 : ef3ce000  r8 : c049229c
[  225.652927] r7 : ef304c3c  r6 : c04b4f30  r5 : ef304c08  r4 : ef304000
[  225.659466] r3 : ef304c08  r2 : 00000000  r1 : 00000000  r0 : ef304c00
[  225.666005] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  225.673153] Control: 10c5387d  Table: 2ea2c019  DAC: 00000015
[  225.678909] Process init (pid: 1100, stack limit = 0xef3ce238)

Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Cc: Chris Ball <cjb@xxxxxxxxxx>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@xxxxxxxxxxxxxxxxxx>
---
This patch applies cleanly on today's linux-next.

Honestly, I can't see how the owner pointer can be NULL,
but every other bus driver is checking, so I guess it can
be NULL under some circumstance.

 drivers/mmc/core/bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index b9e5bea..8fcf0b9 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -129,7 +129,8 @@ static void mmc_bus_shutdown(struct device *dev)
 	struct mmc_host *host = card->host;
 	int ret;
 
-	drv->shutdown(card);
+	if (drv)
+		drv->shutdown(card);
 
 	if (host->bus_ops->shutdown) {
 		ret = host->bus_ops->shutdown(host);
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux