All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yan Cangang <nalanzeyu@gmail.com>
Cc: nbd@nbd.name, john@phrozen.org, sean.wang@mediatek.com,
	Mark-MC.Lee@mediatek.com, netdev@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: mtk_eth_soc: fix memory leak in mtk_ppe_init()
Date: Mon, 14 Nov 2022 09:59:18 +0200	[thread overview]
Message-ID: <Y3H1VgVOJB5kHbaa@unreal> (raw)
In-Reply-To: <20221112233239.824389-1-nalanzeyu@gmail.com>

On Sun, Nov 13, 2022 at 07:32:39AM +0800, Yan Cangang wrote:
>     When dmam_alloc_coherent() or devm_kzalloc() failed, the rhashtable
>     ppe->l2_flows isn't destroyed. Fix it.
 ^^^^^
Please fix indentation in commit message.

> 
> Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
> Signed-off-by: Yan Cangang <nalanzeyu@gmail.com>
> ---
>  drivers/net/ethernet/mediatek/mtk_ppe.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 2d8ca99f2467..8da4c8be59fd 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -737,7 +737,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base,
>  				  MTK_PPE_ENTRIES * soc->foe_entry_size,
>  				  &ppe->foe_phys, GFP_KERNEL);
>  	if (!foe)
> -		return NULL;
> +		goto err_free_l2_flows;
>  
>  	ppe->foe_table = foe;
>  
> @@ -745,11 +745,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base,
>  			sizeof(*ppe->foe_flow);
>  	ppe->foe_flow = devm_kzalloc(dev, foe_flow_size, GFP_KERNEL);
>  	if (!ppe->foe_flow)
> -		return NULL;
> +		goto err_free_l2_flows;
>  
>  	mtk_ppe_debugfs_init(ppe, index);
>  
>  	return ppe;
> +
> +err_free_l2_flows:
> +	rhashtable_destroy(&ppe->l2_flows);

I expect the same change to be in mtk_mdio_cleanup() too.

Thanks


> +	return NULL;
>  }
>  
>  static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe)
> -- 
> 2.30.2
> 

  reply	other threads:[~2022-11-14  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 23:32 [PATCH] net: ethernet: mtk_eth_soc: fix memory leak in mtk_ppe_init() Yan Cangang
2022-11-14  7:59 ` Leon Romanovsky [this message]
2022-11-16  5:14   ` [PATCH v2] net: ethernet: mtk_eth_soc: fix memory leak in error path Yan Cangang
2022-11-17  9:50     ` Leon Romanovsky
2022-11-18  5:13     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3H1VgVOJB5kHbaa@unreal \
    --to=leon@kernel.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=john@phrozen.org \
    --cc=nalanzeyu@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.