diff options
author | Balaji T K <balajitk@ti.com> | 2012-11-19 11:29:55 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-12-06 13:54:54 -0500 |
commit | 25e1897bf59b917a696b84b8cf28a5373157404d (patch) | |
tree | 34b1186e075e071c446c61ac819234c85b53958f /drivers/mmc | |
parent | ab269128a2cff7abee06f023e6466fc29991738c (diff) |
mmc: omap_hsmmc: Fix Oops in case of data errors
ae4bf788ee9 ("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>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 5434fd8e088a..0fcf792af823 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, | |||
969 | __func__); | 969 | __func__); |
970 | } | 970 | } |
971 | 971 | ||
972 | static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, int err) | 972 | static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, |
973 | int err, int end_cmd) | ||
973 | { | 974 | { |
974 | omap_hsmmc_reset_controller_fsm(host, SRC); | 975 | omap_hsmmc_reset_controller_fsm(host, SRC); |
975 | host->cmd->error = err; | 976 | if (end_cmd) { |
977 | if (host->cmd) | ||
978 | host->cmd->error = err; | ||
979 | } | ||
976 | 980 | ||
977 | if (host->data) { | 981 | if (host->data) { |
978 | omap_hsmmc_reset_controller_fsm(host, SRD); | 982 | omap_hsmmc_reset_controller_fsm(host, SRD); |
@@ -991,14 +995,16 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) | |||
991 | 995 | ||
992 | if (status & ERR) { | 996 | if (status & ERR) { |
993 | omap_hsmmc_dbg_report_irq(host, status); | 997 | omap_hsmmc_dbg_report_irq(host, status); |
998 | |||
999 | if (status & (CMD_TIMEOUT | CMD_CRC)) | ||
1000 | end_cmd = 1; | ||
994 | if (status & (CMD_TIMEOUT | DATA_TIMEOUT)) | 1001 | if (status & (CMD_TIMEOUT | DATA_TIMEOUT)) |
995 | hsmmc_command_incomplete(host, -ETIMEDOUT); | 1002 | hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); |
996 | else if (status & (CMD_CRC | DATA_CRC)) | 1003 | else if (status & (CMD_CRC | DATA_CRC)) |
997 | hsmmc_command_incomplete(host, -EILSEQ); | 1004 | hsmmc_command_incomplete(host, -EILSEQ, end_cmd); |
998 | 1005 | ||
999 | end_cmd = 1; | ||
1000 | if (host->data || host->response_busy) { | 1006 | if (host->data || host->response_busy) { |
1001 | end_trans = 1; | 1007 | end_trans = !end_cmd; |
1002 | host->response_busy = 0; | 1008 | host->response_busy = 0; |
1003 | } | 1009 | } |
1004 | } | 1010 | } |