ieee802154: hwsim: Fix possible memory leak in hwsim_subscribe_all_others
Subsystems (3)
PATCH 1/1 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.
--- drivers/net/ieee802154/mac802154_hwsim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ieee802154/mac802154_hwsim.c +2 -2
@@ -715,6 +715,8 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)return 0 ; +sub_fail: +hwsim_edge_unsubscribe_me (phy); me_fail:rcu_read_lock ();list_for_each_entry_rcu (e, &phy->edges, list) {
@@ -722,8 +724,6 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)hwsim_free_edge (e); }rcu_read_unlock (); -sub_fail: -hwsim_edge_unsubscribe_me (phy);return -ENOMEM ; }
Signature · 1 line
2.25.1
Alexander Aring
maintainerHi,
Quoted 25 lines · Dongliang Mu
In
hwsim_subscribe_all_others, the error handling code performs incorrectly if the secondhwsim_alloc_edgefails. When this issue occurs, it goes tosub_fail, without cleaning the edges allocated before.Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")Signed-off-by Dongliang Mu <[email protected]>--- drivers/net/ieee802154/mac802154_hwsim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ieee802154/mac802154_hwsim.c +2
-0@@ -715,6 +715,8 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)return 0 ; +sub_fail: +hwsim_edge_unsubscribe_me (phy); me_fail:rcu_read_lock ();list_for_each_entry_rcu (e, &phy->edges, list) {
drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_subscribe_all_others(struct hwsim_phy *phy) · line 725
Quoted 4 lines
drivers/net/ieee802154/mac802154_hwsim.c +0
-1@@ -722,8 +724,6 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)hwsim_free_edge (e); }rcu_read_unlock (); -sub_fail:
this goto needs to be removed and all goto cases need to end in me_fail (better named to be fail only).
In an error case both loops need to be iterated again to cleanup.
- Alex
Hi,
Quoted 7 lines · Dongliang Mu
In
hwsim_subscribe_all_others, the error handling code performs incorrectly if the secondhwsim_alloc_edgefails. When this issue occurs, it goes tosub_fail, without cleaning the edges allocated before.Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")Signed-off-by Dongliang Mu <[email protected]>
sorry, it is a correct fix. Thanks.
- Alex
Stefan Schmidt
maintainerHello.
Quoted 8 lines · Alexander Aring
Hi,
Quoted 5 lines · Dongliang Mu
In
hwsim_subscribe_all_others, the error handling code performs incorrectly if the secondhwsim_alloc_edgefails. When this issue occurs, it goes tosub_fail, without cleaning the edges allocated before.
Quoted 6 lines
Quoted 2 lines
Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")Signed-off-by Dongliang Mu <[email protected]>Acked-by Alexander Aring <[email protected]>sorry, it is a correct fix. Thanks.
This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!
regards
Stefan Schmidt