Skip to content

Commit ab372c2

Browse files
mudongliangStefan-Schmidt
authored andcommitted
ieee802154: hwsim: Fix possible memory leak in hwsim_subscribe_all_others
In hwsim_subscribe_all_others, the error handling code performs incorrectly if the second hwsim_alloc_edge fails. When this issue occurs, it goes to sub_fail, without cleaning the edges allocated before. Fixes: f25da51 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> Acked-by: Alexander Aring <aahringo@redhat.com> Link: https://lore.kernel.org/r/20210611015812.1626999-1-mudongliangabcd@gmail.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
1 parent f2386cf commit ab372c2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/net/ieee802154/mac802154_hwsim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,15 +715,15 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
715715

716716
return 0;
717717

718+
sub_fail:
719+
hwsim_edge_unsubscribe_me(phy);
718720
me_fail:
719721
rcu_read_lock();
720722
list_for_each_entry_rcu(e, &phy->edges, list) {
721723
list_del_rcu(&e->list);
722724
hwsim_free_edge(e);
723725
}
724726
rcu_read_unlock();
725-
sub_fail:
726-
hwsim_edge_unsubscribe_me(phy);
727727
return -ENOMEM;
728728
}
729729

0 commit comments

Comments
 (0)