diff mbox series

[1/1] drivers/net/ethernet: fix a memory leak

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

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: davem@davemloft.net edumazet@google.com pabeni@redhat.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuanjun Gong July 22, 2022, 4:33 a.m. UTC
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(+)

Comments

Kunihiko Hayashi July 22, 2022, 10:46 a.m. UTC | #1
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 mbox series

Patch

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;
 }