From 976ea2411261287b605e39922bbde21d3f457045 Mon Sep 17 00:00:00 2001 From: Zhou Yanjie Date: Thu, 18 Jul 2019 19:57:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?sdio:=20mmc.c:=20=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E8=AE=A1=E7=AE=97=E8=BF=87=E7=A8=8B=E6=BA=A2?= =?UTF-8?q?=E5=87=BA/Prevent=20capacity=20calculation=20overflow.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改“mmc_parse_ext_csd”函数,防止容量计算过程溢出。 Modify the "mmc_parse_ext_csd" function to prevent the capacity calculation process from overflowing. Signed-off-by: Zhou Yanjie --- components/drivers/sdio/mmc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index 5c7ddcb258..34e91ea386 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -182,6 +182,8 @@ static int mmc_get_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t **new_ext_csd) */ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) { + rt_uint64_t card_capacity = 0; + if(card == RT_NULL || ext_csd == RT_NULL) { LOG_E("emmc parse ext csd fail, invaild args"); @@ -191,9 +193,10 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) card->flags |= CARD_FLAG_HIGHSPEED; card->hs_max_data_rate = 200000000; - card->card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]); - card->card_capacity *= card->card_blksize; - card->card_capacity >>= 10; /* unit:KB */ + card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]); + card_capacity *= card->card_blksize; + card_capacity >>= 10; /* unit:KB */ + card->card_capacity = card_capacity; LOG_I("emmc card capacity %d KB.", card->card_capacity); return 0; From de69a9b5003a77923a0dc7ecb4dd21c48248419a Mon Sep 17 00:00:00 2001 From: Zhou Yanjie Date: Fri, 19 Jul 2019 16:46:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?sdio:=20mmc.c:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BC=A9=E8=BF=9B/Fix=20indentation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复版权信息中的缩进格式。 Fix indentation in copyright information. Signed-off-by: Zhou Yanjie --- components/drivers/sdio/mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index 34e91ea386..7b1f7ee193 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2015-06-15 hichard first version + * Date Author Notes + * 2015-06-15 hichard first version */ #include