diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index 6a55e85a3d..cc4e24e3c8 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -252,7 +252,7 @@ static rt_size_t rt_mmcsd_read(rt_device_t dev, void *buffer, rt_size_t size) { - rt_err_t err; + rt_err_t err = 0; rt_size_t offset = 0; rt_size_t req_size = 0; rt_size_t remain_size = size; @@ -293,7 +293,7 @@ static rt_size_t rt_mmcsd_write(rt_device_t dev, const void *buffer, rt_size_t size) { - rt_err_t err; + rt_err_t err = 0; rt_size_t offset = 0; rt_size_t req_size = 0; rt_size_t remain_size = size; diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index e617c115f4..efda67c087 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -198,6 +198,12 @@ 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) { + if(card == RT_NULL || ext_csd == RT_NULL) + { + LOG_E("emmc parse ext csd fail, invaild args"); + return -1; + } + card->flags |= CARD_FLAG_HIGHSPEED; card->hs_max_data_rate = 200000000; @@ -424,7 +430,7 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, { rt_int32_t err; rt_uint32_t resp[4]; - rt_uint32_t rocr; + rt_uint32_t rocr = 0; rt_uint32_t max_data_rate; rt_uint8_t *ext_csd = RT_NULL; struct rt_mmcsd_card *card = RT_NULL; diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 67e82156b3..7b38c39570 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -140,6 +140,7 @@ rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card, RT_ASSERT(card != RT_NULL); RT_ASSERT(fn <= SDIO_MAX_FUNCTIONS); + RT_ASSERT(pdata != RT_NULL); if (reg_addr & ~SDIO_ARG_CMD53_REG_MASK) return -RT_ERROR; @@ -937,6 +938,7 @@ err3: host->card->sdio_function[i] = RT_NULL; rt_free(host->card); host->card = RT_NULL; + break; } } }