# Re: \[PATCH v2\] ieee802154: hwsim: Fix memory leak in hwsim\_add\_one

- From: Alexander Aring \<alex.aring@gmail.com\>
- Date: 2021-06-22 18:30:01 
- List: netdev
- Page: https://ratatoskr.run/netdev/2021/06/1422907
- Thread: https://ratatoskr.run/netdev/2021/06/1415750/t.md

```text
Hi,

On Tue, 15 Jun 2021 at 22:09, Dongliang Mu [ref] wrote:
>
> 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: <redacted>
> Fixes: 1c9f4a3fce77 ("ieee802154: hwsim: fix rcu handling")
> Signed-off-by: Dongliang Mu <redacted>

Acked-by: Alexander Aring <aahringo@redhat.com>

Thanks!
```
