Message ID | 20220722043327.2259-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/1] drivers/net/ethernet: fix a memory leak | expand |
Hi, On 2022/07/22 13:33, Yuanjun Gong wrote: > In ave_remove, ndev should be freed with free_netdev before return. > > Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> > --- > drivers/net/ethernet/socionext/sni_ave.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/socionext/sni_ave.c > b/drivers/net/ethernet/socionext/sni_ave.c > index f0c8de2c6075..9d1c1cdd04af 100644 > --- a/drivers/net/ethernet/socionext/sni_ave.c > +++ b/drivers/net/ethernet/socionext/sni_ave.c > @@ -1725,6 +1725,7 @@ static int ave_remove(struct platform_device *pdev) > unregister_netdev(ndev); > netif_napi_del(&priv->napi_rx); > netif_napi_del(&priv->napi_tx); > + free_netdev(ndev); This ave driver uses devm_allocate_etherdev() to allocate "ndev". It will be released automatically when removing the driver. Therefore, it is not necessary to release it explicitly. Please refer to the commit e87fb82ddc3b ("net: ethernet: ave: Replace alloc_etherdev() with devm_alloc_etherdev()"). Thank you, > > return 0; > } > --- Best Regards Kunihiko Hayashi
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index f0c8de2c6075..9d1c1cdd04af 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1725,6 +1725,7 @@ static int ave_remove(struct platform_device *pdev) unregister_netdev(ndev); netif_napi_del(&priv->napi_rx); netif_napi_del(&priv->napi_tx); + free_netdev(ndev); return 0; }
In ave_remove, ndev should be freed with free_netdev before return. Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- drivers/net/ethernet/socionext/sni_ave.c | 1 + 1 file changed, 1 insertion(+)