Skip to contentSkip to conversation

mmc: sdhci: Fix host->cmd is null

PATCH In review Wenchao Chen 3 participants 3 messages Sep 7, 2022 – Sep 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/5 mmc: sdhci: Fix host->cmd is null

From: Wenchao Chen <[email protected]>

When data crc occurs, the kernel will panic because host->cmd is null.

---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
index 7689ffe..2511728 100644
@@ -3928,7 +3928,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
 	if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) {
 		*cmd_error = -EILSEQ;
-		if (!mmc_op_tuning(host->cmd->opcode))
+		if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
 			sdhci_err_stats_inc(host, CMD_CRC);
 	} else if (intmask & SDHCI_INT_TIMEOUT) {
 		*cmd_error = -ETIMEDOUT;
@@ -3938,7 +3938,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
 	if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) {
 		*data_error = -EILSEQ;
-		if (!mmc_op_tuning(host->cmd->opcode))
+		if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
 			sdhci_err_stats_inc(host, DAT_CRC);
 	} else if (intmask & SDHCI_INT_DATA_TIMEOUT) {
 		*data_error = -ETIMEDOUT;
Signature · 1 line
2.7.4
maintainer Acked-by on v1 5/5
#1 lore raw

Don't know what is going on with the "Vx 5/5"? Ignoring it.

Quoted 4 lines · Wenchao Chen

From: Wenchao Chen <[email protected]>

When data crc occurs, the kernel will panic because host->cmd is null.

Fixes efe8f5c9b5e1 ("mmc: sdhci: Capture eMMC and SD card errors")
Quoted 1 line

Thank you!

Quoted 26 lines
---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
index 7689ffe..2511728 100644
@@ -3928,7 +3928,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
 	if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) {
 		*cmd_error = -EILSEQ;
-		if (!mmc_op_tuning(host->cmd->opcode))
+		if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
 			sdhci_err_stats_inc(host, CMD_CRC);
 	} else if (intmask & SDHCI_INT_TIMEOUT) {
 		*cmd_error = -ETIMEDOUT;
@@ -3938,7 +3938,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
 	if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) {
 		*data_error = -EILSEQ;
-		if (!mmc_op_tuning(host->cmd->opcode))
+		if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
 			sdhci_err_stats_inc(host, DAT_CRC);
 	} else if (intmask & SDHCI_INT_DATA_TIMEOUT) {
 		*data_error = -ETIMEDOUT;
#2 lore raw
In reply to Wenchao Chen
Quoted 6 lines · Wenchao Chen

From: Wenchao Chen <[email protected]>

When data crc occurs, the kernel will panic because host->cmd is null.

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 29 lines
---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -3
index 7689ffe..2511728 100644
@@ -3928,7 +3928,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
        if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) {
                *cmd_error = -EILSEQ;
-               if (!mmc_op_tuning(host->cmd->opcode))
+               if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
                        sdhci_err_stats_inc(host, CMD_CRC);
        } else if (intmask & SDHCI_INT_TIMEOUT) {
                *cmd_error = -ETIMEDOUT;
@@ -3938,7 +3938,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
 
        if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) {
                *data_error = -EILSEQ;
-               if (!mmc_op_tuning(host->cmd->opcode))
+               if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
                        sdhci_err_stats_inc(host, DAT_CRC);
        } else if (intmask & SDHCI_INT_DATA_TIMEOUT) {
                *data_error = -ETIMEDOUT;
--

2.7.4