Browse Source

mmc: fix for old MMCs (below version 4)

The ext_csd is allocated only for MMC above version 4. The compare will
crash or fail for older MMCs.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Jean-Jacques Hiblot 7 years ago
parent
commit
1de06b9fa5
1 changed files with 3 additions and 0 deletions
  1. 3 0
      drivers/mmc/mmc.c

+ 3 - 0
drivers/mmc/mmc.c

@@ -1657,6 +1657,9 @@ static int mmc_read_and_compare_ext_csd(struct mmc *mmc)
 	const u8 *ext_csd = mmc->ext_csd;
 	ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
 
+	if (mmc->version < MMC_VERSION_4)
+		return 0;
+
 	err = mmc_send_ext_csd(mmc, test_csd);
 	if (err)
 		return err;