From f260f7effde7bca0546cfebfbdfabf79996f870e Mon Sep 17 00:00:00 2001 From: ZYH Date: Sat, 22 Sep 2018 14:49:47 +0800 Subject: [PATCH 1/5] [Components][SDIO]fix Assigned value is garbage or undefined --- components/drivers/sdio/sdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 67e82156b3..4c669e808c 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; From f6be7abb2d579596fdcf2141f3541ced7aeda96b Mon Sep 17 00:00:00 2001 From: ZYH Date: Sat, 22 Sep 2018 14:53:08 +0800 Subject: [PATCH 2/5] [Components][SDIO]block 'err' declared without an initial value --- components/drivers/sdio/block_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 3d69c44ab8a3bfc30176b45f8eeeab60dda802b2 Mon Sep 17 00:00:00 2001 From: ZYH Date: Sat, 22 Sep 2018 14:56:55 +0800 Subject: [PATCH 3/5] [Components][SDIO]fix Null point access --- components/drivers/sdio/sdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 4c669e808c..7b38c39570 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -938,6 +938,7 @@ err3: host->card->sdio_function[i] = RT_NULL; rt_free(host->card); host->card = RT_NULL; + break; } } } From 780f538525637eaed5315c66ee1c52228c16b1d6 Mon Sep 17 00:00:00 2001 From: ZYH Date: Sat, 22 Sep 2018 15:02:48 +0800 Subject: [PATCH 4/5] [Components][SDIO][MMC] fix null point check --- components/drivers/sdio/mmc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index e617c115f4..b928119b7d 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(RT_NULL == card || RT_NULL == ext_csd) + { + LOG_E("emmc parse ext csd fail, invaild args"); + return -1; + } + card->flags |= CARD_FLAG_HIGHSPEED; card->hs_max_data_rate = 200000000; From 2e74539130d41add6c729d231603ee2cb2e6729d Mon Sep 17 00:00:00 2001 From: ZYH Date: Sat, 22 Sep 2018 15:05:05 +0800 Subject: [PATCH 5/5] [Components][SDIO]fix 'rocr' declared without an initial value --- components/drivers/sdio/mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index b928119b7d..efda67c087 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -198,12 +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(RT_NULL == card || RT_NULL == 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; @@ -430,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;