Linux-WPAN Archive on
 help / color / Atom feed
* [PATCH] ieee802154: hwsim: Fix memory leak in hwsim_add_one
@ 2021-06-15 11:24 Dongliang Mu
  0 siblings, 0 replies; only message in thread
From: Dongliang Mu @ 2021-06-15 11:24 UTC (permalink / raw)
  To: alex.aring, stefan, davem, kuba
  Cc: linux-wpan, linux-kernel, netdev, Dongliang Mu,

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

    |                            |
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).

Fixes: 1c9f4a3fce77 ("ieee802154: hwsim: fix rcu handling")
Signed-off-by: Dongliang Mu <>
 drivers/net/ieee802154/mac802154_hwsim.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index da9135231c07..b05159cff33a 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -824,9 +824,16 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
 static void hwsim_del(struct hwsim_phy *phy)
 	struct hwsim_pib *pib;
+	struct hwsim_edge *e;
+	// remove the edges in the list
+	list_for_each_entry_rcu(e, &phy->edges, list) {
+		list_del_rcu(&e->list);
+		hwsim_free_edge(e);
+	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 11:24 [PATCH] ieee802154: hwsim: Fix memory leak in hwsim_add_one Dongliang Mu

Linux-WPAN Archive on

Archives are clonable:
	git clone --mirror linux-wpan/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-wpan linux-wpan/ \
	public-inbox-index linux-wpan

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone