All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Chen Ni <nichen@iscas.ac.cn>
Cc: nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	lorenzo@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net-next v2] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init
Date: Mon, 27 May 2024 16:42:49 -0700	[thread overview]
Message-ID: <20240527164249.4aafd105@kernel.org> (raw)
In-Reply-To: <20240517023922.362327-1-nichen@iscas.ac.cn>

On Fri, 17 May 2024 10:39:22 +0800 Chen Ni wrote:
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index cae46290a7ae..f9b8956a8726 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -4957,7 +4957,7 @@ static int mtk_probe(struct platform_device *pdev)
>  
>  			eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, i);
>  
> -			if (!eth->ppe[i]) {
> +			if (IS_ERR_OR_NULL(eth->ppe[i])) {
>  				err = -ENOMEM;

You still discard the real error here.

>  				goto err_deinit_ppe;
>  			}
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 0acee405a749..4895c6febaf8 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -884,12 +884,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
>  	struct mtk_ppe *ppe;
>  	u32 foe_flow_size;
>  	void *foe;
> +	int ret;
>  
>  	ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
>  	if (!ppe)
>  		return NULL;

Please convert the return NULL in this function to 
return ERR_PTR(-ENOMEM) and use the error code in mtk_probe()

> -	rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	if (ret)
> +		return ERR_PTR(ret);

Also there are two direct return NULLs without calling rhashtable_destroy()
later in this function. Please fix that in a separate patch.

>  	/* need to allocate a separate device, since it PPE DMA access is
>  	 * not coherent.


WARNING: multiple messages have this Message-ID (diff)
From: Jakub Kicinski <kuba@kernel.org>
To: Chen Ni <nichen@iscas.ac.cn>
Cc: nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	lorenzo@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net-next v2] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init
Date: Mon, 27 May 2024 16:42:49 -0700	[thread overview]
Message-ID: <20240527164249.4aafd105@kernel.org> (raw)
In-Reply-To: <20240517023922.362327-1-nichen@iscas.ac.cn>

On Fri, 17 May 2024 10:39:22 +0800 Chen Ni wrote:
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index cae46290a7ae..f9b8956a8726 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -4957,7 +4957,7 @@ static int mtk_probe(struct platform_device *pdev)
>  
>  			eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, i);
>  
> -			if (!eth->ppe[i]) {
> +			if (IS_ERR_OR_NULL(eth->ppe[i])) {
>  				err = -ENOMEM;

You still discard the real error here.

>  				goto err_deinit_ppe;
>  			}
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 0acee405a749..4895c6febaf8 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -884,12 +884,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
>  	struct mtk_ppe *ppe;
>  	u32 foe_flow_size;
>  	void *foe;
> +	int ret;
>  
>  	ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
>  	if (!ppe)
>  		return NULL;

Please convert the return NULL in this function to 
return ERR_PTR(-ENOMEM) and use the error code in mtk_probe()

> -	rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	if (ret)
> +		return ERR_PTR(ret);

Also there are two direct return NULLs without calling rhashtable_destroy()
later in this function. Please fix that in a separate patch.

>  	/* need to allocate a separate device, since it PPE DMA access is
>  	 * not coherent.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-05-27 23:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  2:39 [PATCH net-next v2] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init Chen Ni
2024-05-17  2:39 ` Chen Ni
2024-05-27 23:42 ` Jakub Kicinski [this message]
2024-05-27 23:42   ` 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=20240527164249.4aafd105@kernel.org \
    --to=kuba@kernel.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=nichen@iscas.ac.cn \
    --cc=pabeni@redhat.com \
    --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.