# Re: \[PATCH net\] eth: sp7021: drop free\_netdev() from spl2sw\_init\_netdev()

- From: Francois Romieu \<romieu@fr.zoreil.com\>
- Date: 2022-11-09 22:04:30 
- List: netdev
- Page: https://ratatoskr.run/netdev/2022/11/11244236
- Thread: https://ratatoskr.run/netdev/2022/11/11244181/t.md

```text
Eric Dumazet [ref] :
[...]
> > diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
> > index 9be585237277..c499a14314f1 100644
> > --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
> > +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
> > @@ -287,7 +287,6 @@ static u32 spl2sw_init_netdev(struct platform_device *pdev, u8 *mac_addr,
> >         if (ret) {
> >                 dev_err(&pdev->dev, "Failed to register net device \"%s\"!\n",
> >                         ndev->name);
> 
> If the following leads to a double free, how the previous use of
> ndev->name would actually work ?

The second free_netdev happens when device managed resources are released.
ndev->name above is used before the first free_netdev.

-- 
Ueimor
```
