From: Kuninori Morimoto Date: Mon, 11 May 2015 07:34:53 +0000 (+0000) Subject: mmc: cast u8 to unsigned long long to avoid unexpected error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ded8a5f9613dbb62cd74f9f26a9caa3193eb3764;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mmc: cast u8 to unsigned long long to avoid unexpected error card->ext_csd.enhanced_area_offset is defined as "unsigned long long", and, ext_csd[] is defined as u8. unsigned long long data might have strange data if first bit of ext_csd[] was 1. this patch cast it to (unsigned long long) Special thanks to coverity ex) u8 data8; u64 data64; data8 = 0x80; data64 = (data8 << 24); // 0xffffffff80000000 data64 = (((unsigned long long)data8) << 24); // 0x80000000; Signed-off-by: Kuninori Morimoto Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index a8028633253a..03c94c2f23e1 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -267,8 +267,10 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) * calculate the enhanced data area offset, in bytes */ card->ext_csd.enhanced_area_offset = - (ext_csd[139] << 24) + (ext_csd[138] << 16) + - (ext_csd[137] << 8) + ext_csd[136]; + (((unsigned long long)ext_csd[139]) << 24) + + (((unsigned long long)ext_csd[138]) << 16) + + (((unsigned long long)ext_csd[137]) << 8) + + (((unsigned long long)ext_csd[136])); if (mmc_card_blockaddr(card)) card->ext_csd.enhanced_area_offset <<= 9; /*