diff options
| author | Bernard Xiong <[email protected]> | 2022-11-03 23:29:45 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-03 23:29:45 +0800 |
| commit | 20207fbcd4dc2fe5515b4f33e3a3820f5828c50f (patch) | |
| tree | fe330365c8eb7293c32099f743dab3d9d80c3d97 | |
| parent | fb10694b1625654fc18b7258a752c967b3ddace5 (diff) | |
| parent | e663d2d8708cd77be1c03983c82474b0ea3a3114 (diff) | |
Merge pull request #6583 from mxgsgtc/bugfix-remove-sdcard-blockdev
[components/sdio] bugfix: remove sdcard block dev may cause a infinite loop.
| -rw-r--r-- | components/drivers/sdio/block_dev.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index c8bb2f7c68..522fa753db 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -505,6 +505,18 @@ void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card) rt_list_t *l, *n; struct mmcsd_blk_device *blk_dev; + if(card == RT_NULL) + { + LOG_E("card is null!"); + return; + } + + if(rt_list_isempty(&card->blk_devices)) + { + LOG_E("card blk_devices is empty!"); + return; + } + for (l = (&card->blk_devices)->next, n = l->next; l != &card->blk_devices; l = n, n=n->next) { blk_dev = (struct mmcsd_blk_device *)rt_list_entry(l, struct mmcsd_blk_device, list); |
