linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] mmc: omap_hsmmc: Fix Oops in case of data errors
@ 2012-11-19 16:29 Venkatraman S
  2012-11-19 16:29 ` [PATCH 2/7] mmc: omap_hsmmc: no reset of cmd state machine for DCRC Venkatraman S
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Venkatraman S @ 2012-11-19 16:29 UTC (permalink / raw)
  To: cjb; +Cc: linux-mmc, linux-omap, Balaji T K, Venkatraman S

From: Balaji T K <balajitk@ti.com>

"commit ae4bf788ee9bf7c2d51b0309117d1fcccbdd50a2
mmc: omap_hsmmc: consolidate error report handling of HSMMC IRQ"
sets both end_cmd and end_trans to 1.

Setting end_cmd to 1 for Data Timeout/CRC leads to NULL pointer dereference of
host->cmd as the command complete has previously been handled.
Set end_cmd only in case of command Timeout/CRC.

Moreover host->cmd->error should not be updated on data error case, only
host->data->error needs to be updated.

Signed-off-by: Balaji T K <balajitk@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Venkatraman S <svenkatr@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 5434fd8..0fcf792 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -969,10 +969,14 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,
 			__func__);
 }
 
-static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, int err)
+static void hsmmc_command_incomplete(struct omap_hsmmc_host *host,
+					int err, int end_cmd)
 {
 	omap_hsmmc_reset_controller_fsm(host, SRC);
-	host->cmd->error = err;
+	if (end_cmd) {
+		if (host->cmd)
+			host->cmd->error = err;
+	}
 
 	if (host->data) {
 		omap_hsmmc_reset_controller_fsm(host, SRD);
@@ -991,14 +995,16 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 
 	if (status & ERR) {
 		omap_hsmmc_dbg_report_irq(host, status);
+
+		if (status & (CMD_TIMEOUT | CMD_CRC))
+			end_cmd = 1;
 		if (status & (CMD_TIMEOUT | DATA_TIMEOUT))
-			hsmmc_command_incomplete(host, -ETIMEDOUT);
+			hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd);
 		else if (status & (CMD_CRC | DATA_CRC))
-			hsmmc_command_incomplete(host, -EILSEQ);
+			hsmmc_command_incomplete(host, -EILSEQ, end_cmd);
 
-		end_cmd = 1;
 		if (host->data || host->response_busy) {
-			end_trans = 1;
+			end_trans = !end_cmd;
 			host->response_busy = 0;
 		}
 	}
-- 
1.8.0


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

end of thread, other threads:[~2012-11-26 12:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19 16:29 [PATCH 1/7] mmc: omap_hsmmc: Fix Oops in case of data errors Venkatraman S
2012-11-19 16:29 ` [PATCH 2/7] mmc: omap_hsmmc: no reset of cmd state machine for DCRC Venkatraman S
2012-11-19 16:29 ` [PATCH 3/7] mmc: omap_hsmmc: update error code for response_busy cmd Venkatraman S
2012-11-19 16:29 ` [PATCH 4/7] mmc: omap_hsmmc: Enable HSPE bit for high speed cards Venkatraman S
2012-11-19 16:29 ` [PATCH 5/7] mmc: omap_hsmmc: introduce omap_hsmmc_prepare/complete Venkatraman S
2012-11-19 16:30 ` [PATCH 6/7] mmc: omap_hsmmc: convert critical failure reports to dev_err Venkatraman S
2012-11-19 16:30 ` [PATCH v2 7/7] mmc: omap_hsmmc: Cleanup up bitmap definitions of Interrupt Register Venkatraman S
2012-11-25 20:49 ` [PATCH 1/7] mmc: omap_hsmmc: Fix Oops in case of data errors Chris Ball
2012-11-26 12:02   ` Venkatraman S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).