Skip to content

Commit 28a5501

Browse files
mudongliangStefan-Schmidt
authored andcommitted
ieee802154: hwsim: Fix memory leak in hwsim_add_one
No matter from hwsim_remove or hwsim_del_radio_nl, hwsim_del fails to remove the entry in the edges list. Take the example below, phy0, phy1 and e0 will be deleted, resulting in e1 not freed and accessed in the future. hwsim_phys | ------------------------------ | | phy0 (edges) phy1 (edges) ----> e1 (idx = 1) ----> e0 (idx = 0) Fix this by deleting and freeing all the entries in the edges list between hwsim_edge_unsubscribe_me and list_del(&phy->list). Reported-by: [email protected] Fixes: 1c9f4a3 ("ieee802154: hwsim: fix rcu handling") Signed-off-by: Dongliang Mu <[email protected]> Acked-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent ab372c2 commit 28a5501

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/ieee802154/mac802154_hwsim.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,17 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
824824
static void hwsim_del(struct hwsim_phy *phy)
825825
{
826826
struct hwsim_pib *pib;
827+
struct hwsim_edge *e;
827828

828829
hwsim_edge_unsubscribe_me(phy);
829830

830831
list_del(&phy->list);
831832

832833
rcu_read_lock();
834+
list_for_each_entry_rcu(e, &phy->edges, list) {
835+
list_del_rcu(&e->list);
836+
hwsim_free_edge(e);
837+
}
833838
pib = rcu_dereference(phy->pib);
834839
rcu_read_unlock();
835840

0 commit comments

Comments
 (0)