提交 976ea241 编写于 作者: Z Zhou Yanjie

sdio: mmc.c: 防止容量计算过程溢出/Prevent capacity calculation overflow.

修改“mmc_parse_ext_csd”函数,防止容量计算过程溢出。

Modify the "mmc_parse_ext_csd" function to prevent the capacity
calculation process from overflowing.
Signed-off-by: NZhou Yanjie <zhouyanjie@zoho.com>
上级 9a1be9e7
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册