Subject: Re: [PATCH v2] net: ethernet: mtk_eth_soc: fix memory leak in error path

From: Leon Romanovsky <[email-masked]>
Date: Thu, 17 Nov 2022 11:50:59 +0200

On Wed, Nov 16, 2022 at 01:14:07PM +0800, Yan Cangang wrote:
> In mtk_ppe_init(), when dmam_alloc_coherent() or devm_kzalloc() failed,
> the rhashtable ppe->l2_flows isn't destroyed. Fix it.
> 
> In mtk_probe(), when mtk_eth_offload_init() or register_netdev() failed,
> have the same problem. Also, call to mtk_mdio_cleanup() is missed in this
> case. Fix it.
> 
> Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
> Fixes: ba37b7caf1ed ("net: ethernet: mtk_eth_soc: add support for initializing the PPE")
> Fixes: 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")
> Signed-off-by: Yan Cangang <[email-masked]>
> ---
> v1: https://lore.kernel.org/netdev/[email-masked]/T/
> v2:
>   - clean up commit message
>   - new mtk_ppe_deinit() function, call it before calling mtk_mdio_cleanup()

Subject line should include target [PATCH net v2] ....

> 
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c |  9 +++++----
>  drivers/net/ethernet/mediatek/mtk_ppe.c     | 19 +++++++++++++++++--
>  drivers/net/ethernet/mediatek/mtk_ppe.h     |  1 +
>  3 files changed, 23 insertions(+), 6 deletions(-)

The change seems ok, but please be aware that mtk_eth_offload_init()
calls to rhashtable_init() which is not destroyed too.

Thanks,
Reviewed-by: Leon Romanovsky <[email-masked]>