Skip to content

Commit c2f5a28

Browse files
HuoyanlifusuRbb666
authored andcommitted
[components][sdio] fix possible memory leak of sdio driver unregistration
1 parent 678473c commit c2f5a28

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎components/drivers/sdio/dev_sdio.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,10 +1378,11 @@ rt_int32_t sdio_unregister_driver(struct rt_sdio_driver *driver)
13781378
for (l = (&sdio_drivers)->next; l != &sdio_drivers; l = l->next)
13791379
{
13801380
sd = (struct sdio_driver *)rt_list_entry(l, struct sdio_driver, list);
1381-
if (sd->drv != driver)
1381+
if (sd->drv == driver)
13821382
{
1383-
sd = RT_NULL;
1383+
break;
13841384
}
1385+
sd = RT_NULL;
13851386
}
13861387

13871388
if (sd == RT_NULL)
@@ -1396,11 +1397,12 @@ rt_int32_t sdio_unregister_driver(struct rt_sdio_driver *driver)
13961397
if (card != RT_NULL)
13971398
{
13981399
driver->remove(card);
1399-
rt_list_remove(&sd->list);
1400-
rt_free(sd);
14011400
}
14021401
}
14031402

1403+
rt_list_remove(&sd->list);
1404+
rt_free(sd);
1405+
14041406
return 0;
14051407
}
14061408

0 commit comments

Comments
 (0)