[PATCH net] net: ethernet: mtk_ppe: Fix rhashtable leak in mtk_ppe_init error paths

Lorenzo Bianconi lorenzo at kernel.org
Tue Jun 16 23:58:36 PDT 2026


> In mtk_ppe_init(), when accounting is enabled, the error paths for
> dmam_alloc_coherent(mib) and devm_kzalloc(acct) failures return NULL
> directly, bypassing the err_free_l2_flows label that destroys the
> rhashtable initialized earlier.
> 
> While this leak only occurs during probe (not runtime) and the leaked
> memory is minimal (an empty rhash table), fixing it ensures proper
> error path cleanup consistency.
> 
> Fix by changing the two return NULL statements to goto err_free_l2_flows.
> 
> Fixes: 603ea5e7ffa7 ("net: ethernet: mtk_eth_soc: fix memory leak in error path")
> Signed-off-by: Wayen Yan <win847 at gmail.com>

Acked-by: Lorenzo Bianconi <lorenzo at kernel.org>

> ---
>  drivers/net/ethernet/mediatek/mtk_ppe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 18279e2a70..8451dc3fd0 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -918,7 +918,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
>  		mib = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*mib),
>  					  &ppe->mib_phys, GFP_KERNEL);
>  		if (!mib)
> -			return NULL;
> +			goto err_free_l2_flows;
>  
>  		ppe->mib_table = mib;
>  
> @@ -926,7 +926,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
>  				    GFP_KERNEL);
>  
>  		if (!acct)
> -			return NULL;
> +			goto err_free_l2_flows;
>  
>  		ppe->acct_table = acct;
>  	}
> -- 
> 2.51.0
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260617/1027b45b/attachment.sig>


More information about the linux-arm-kernel mailing list