diff options
author | Haibo Chen <haibo.chen@nxp.com> | 2016-01-12 14:36:48 +0800 |
---|---|---|
committer | guoyin.chen <guoyin.chen@freescale.com> | 2016-03-04 15:53:38 +0800 |
commit | ad500dbddef6b78383eead2587a08e4b50403358 (patch) | |
tree | fa15845f48c3816757cb9b5cf3a7323ca7675c81 | |
parent | a15a650e05e1a0f5cfabcf61e20ff543df14f5c8 (diff) | |
download | u-boot-imx-ad500dbddef6b78383eead2587a08e4b50403358.zip u-boot-imx-ad500dbddef6b78383eead2587a08e4b50403358.tar.gz u-boot-imx-ad500dbddef6b78383eead2587a08e4b50403358.tar.bz2 |
MLK-12209 mmc: cast u8 to unsigned long long to avoid unexpected error
unsigned long long data might have strange data if first bit of u8 data
was 1. this patch cast it to (unsigned long long)
ex)
u8 data8;
u64 data64;
data8 = 0x80;
data64 = (data8 << 24); // 0xffffffff80000000
data64 = (((unsigned long long)data8) << 24); // 0x80000000;
(reported by Coverity)
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
-rw-r--r-- | drivers/mmc/mmc.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 5bc8d63..830d9ae 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1188,10 +1188,10 @@ static int mmc_startup(struct mmc *mmc) * ext_csd's capacity is valid if the value is more * than 2GB */ - capacity = ext_csd[EXT_CSD_SEC_CNT] << 0 - | ext_csd[EXT_CSD_SEC_CNT + 1] << 8 - | ext_csd[EXT_CSD_SEC_CNT + 2] << 16 - | ext_csd[EXT_CSD_SEC_CNT + 3] << 24; + capacity = (u64)ext_csd[EXT_CSD_SEC_CNT] << 0 + | (u64)ext_csd[EXT_CSD_SEC_CNT + 1] << 8 + | (u64)ext_csd[EXT_CSD_SEC_CNT + 2] << 16 + | (u64)ext_csd[EXT_CSD_SEC_CNT + 3] << 24; capacity *= MMC_MAX_BLOCK_LEN; if ((capacity >> 20) > 2 * 1024) mmc->capacity_user = capacity; @@ -1263,10 +1263,10 @@ static int mmc_startup(struct mmc *mmc) mmc->enh_user_size *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; mmc->enh_user_size <<= 19; mmc->enh_user_start = - (ext_csd[EXT_CSD_ENH_START_ADDR+3] << 24) + - (ext_csd[EXT_CSD_ENH_START_ADDR+2] << 16) + - (ext_csd[EXT_CSD_ENH_START_ADDR+1] << 8) + - ext_csd[EXT_CSD_ENH_START_ADDR]; + ((u64)ext_csd[EXT_CSD_ENH_START_ADDR+3] << 24) + + ((u64)ext_csd[EXT_CSD_ENH_START_ADDR+2] << 16) + + ((u64)ext_csd[EXT_CSD_ENH_START_ADDR+1] << 8) + + (u64)ext_csd[EXT_CSD_ENH_START_ADDR]; if (mmc->high_capacity) mmc->enh_user_start <<= 9; } @@ -1301,10 +1301,10 @@ static int mmc_startup(struct mmc *mmc) * JEDEC Standard JESD84-B45, 6.2.4 */ if (mmc->high_capacity && part_completed) { - capacity = (ext_csd[EXT_CSD_SEC_CNT]) | - (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) | - (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) | - (ext_csd[EXT_CSD_SEC_CNT + 3] << 24); + capacity = ((u64)ext_csd[EXT_CSD_SEC_CNT]) | + ((u64)ext_csd[EXT_CSD_SEC_CNT + 1] << 8) | + ((u64)ext_csd[EXT_CSD_SEC_CNT + 2] << 16) | + ((u64)ext_csd[EXT_CSD_SEC_CNT + 3] << 24); capacity *= MMC_MAX_BLOCK_LEN; mmc->capacity_user = capacity; } |