summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-07-20 14:01:42 +0800
committerGitHub <[email protected]>2019-07-20 14:01:42 +0800
commit789fb4a938618a52dc971ff90d9f3e56424efb20 (patch)
tree236a93442c20335480a8a33a402e2882cdf5ec9e
parent367c5abeeb19c1ffbbeb537b0e5c846821a06490 (diff)
parentde69a9b5003a77923a0dc7ecb4dd21c48248419a (diff)
Merge pull request #2875 from Ingenic-community/mmc
sdio: mmc.c: 防止容量计算过程溢出/Prevent capacity calculation overflow.
-rw-r--r--components/drivers/sdio/mmc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c
index 5c7ddcb258..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 <drivers/mmcsd_core.h>
@@ -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;