From: Alexander Kochetkov Date: Tue, 20 Feb 2018 11:35:55 +0000 (+0300) Subject: mmc: fix off-by-one bug in mmc_startup_v4() X-Git-Tag: v2018.03-rc4~26^2~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=76584e33988fc9f6c80199e04ca6e249baf7289a;p=u-boot mmc: fix off-by-one bug in mmc_startup_v4() MMC card with EXT_CSD_REV value 9 will trigger off-by-one bug while accessing mmc_versions array. The patch fix that. Signed-off-by: Alexander Kochetkov --- diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 31f65f6e24..c930893300 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1969,7 +1969,7 @@ static int mmc_startup_v4(struct mmc *mmc) return -ENOMEM; memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN); - if (ext_csd[EXT_CSD_REV] > ARRAY_SIZE(mmc_versions)) + if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions)) return -EINVAL; mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];