From 69da1839dea20327bc0e5d36aea467fcc0cba04b Mon Sep 17 00:00:00 2001 From: Yifeng Zhao Date: Wed, 22 Dec 2021 18:09:40 +0800 Subject: [PATCH] mmc: core: add argument check for cmd1 According to eMMC specification v5.1 section A6.1, the R3 response value should be 0x00FF8080, 0x40FF8080, 0x80FF8080 or 0xC0FF8080. The EMMC device may be abnormal if a wrong OCR data is configured. Signed-off-by: Yifeng Zhao Change-Id: I5b19c0a937b55dc75e9d1abf7f9c8cf9a5d083b5 --- drivers/mmc/core/mmc_ops.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 20cf244aaa2d..2715e5031843 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -184,6 +184,15 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) if (err) break; + /* + * According to eMMC specification v5.1 section A6.1, the R3 + * response value should be 0x00FF8080, 0x40FF8080, 0x80FF8080 + * or 0xC0FF8080. The EMMC device may be abnormal if a wrong + * OCR data is configured. + */ + if ((cmd.resp[0] & 0xFFFFFF) != 0x00FF8080) + continue; + /* wait until reset completes */ if (mmc_host_is_spi(host)) { if (!(cmd.resp[0] & R1_SPI_IDLE))