发现了sdio_unregister_driver里的一个bug

发布于 2017-04-19 16:51:20    浏览:1738
rt_list_insert_after(&sdio_drivers, &sd->list);
这句话是多余的,我已经注释掉了。卸载sdio驱动时并不需要将sd插入到sdio_drivers的链表中。相反,由于sd是空指针,执行此句会进入hard fault!
rt_int32_t sdio_unregister_driver(struct rt_sdio_driver *driver)
{
rt_list_t *l;
struct sdio_driver *sd = RT_NULL;
struct rt_mmcsd_card *card;


// rt_list_insert_after(&sdio_drivers, &sd->list);

for (l = (&sdio_drivers)->next; l != &sdio_drivers; l = l->next)
{
sd = (struct sdio_driver *)rt_list_entry(l, struct sdio_driver, list);
if (sd->drv != driver)
{
sd = RT_NULL;
}
}

if (sd == RT_NULL)
{
rt_kprintf("SDIO driver %s not register
", driver->name);
return -RT_ERROR;
}

if (!rt_list_isempty(&sdio_cards))
{
card = sdio_match_driver(driver->id);
if (card != RT_NULL)
{
driver->remove(card);
rt_list_remove(&sd->list);
rt_free(sd);
}
}

return 0;
}

查看更多

2 个回答
bernard
bernard 2017-04-19
This guy hasn't written anything yet
赞!github上发pull request 出来吧

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
1.7k

发布
问题

分享
好友

手机
浏览

扫码手机浏览