mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "s-vadapalli@ti.com" <s-vadapalli@ti.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"srk@ti.com" <srk@ti.com>
Subject: Re: [PATCH net v2] net: ethernet: ti: am65-cpsw: Fix NAPI registration sequence
Date: Tue, 11 Mar 2025 15:25:36 +0000	[thread overview]
Message-ID: <373ae7ef7ff20aa6dccefcb40e2312e9510132b3.camel@siemens.com> (raw)
In-Reply-To: <20250311151833.v3gymfqao4y2zls7@uda0492258>

Hi Siddharth!

On Tue, 2025-03-11 at 20:48 +0530, s-vadapalli@ti.com wrote:
> > > Registering the interrupts for TX or RX DMA Channels prior to registering
> > > their respective NAPI callbacks can result in a NULL pointer dereference.
> > > This is seen in practice as a random occurrence since it depends on the
> > > randomness associated with the generation of traffic by Linux and the
> > > reception of traffic from the wire.
> > > 
> > > Fixes: 681eb2beb3ef ("net: ethernet: ti: am65-cpsw: ensure proper channel cleanup in error path")
> > > Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> > > Co-developed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> > > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> > 
> > ...
> > 
> > 
> > > @@ -2590,10 +2591,11 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
> > >  	return 0;
> > >  
> > >  err_flow:
> > > -	for (--i; i >= 0 ; i--) {
> > > +	netif_napi_del(&flow->napi_rx);
> > 
> > There are totally 3 "goto err_flow;" instances, so if k3_udma_glue_rx_flow_init() or
> > k3_udma_glue_rx_get_irq() would fail on the first iteration, we would come here without
> > a single call to netif_napi_add().
> 
> The following should address this right?

Looks good to me!

> ------------------------------------------------------------------------------------------------
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index b88edf2dd8f4..bef734c6e5c2 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2581,7 +2581,7 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
>                         dev_err(dev, "failure requesting rx %d irq %u, %d\n",
>                                 i, flow->irq, ret);
>                         flow->irq = -EINVAL;
> -                       goto err_flow;
> +                       goto err_request_irq;
>                 }
>         }
> 
> @@ -2590,8 +2590,10 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
> 
>         return 0;
> 
> -err_flow:
> +err_request_irq:
>         netif_napi_del(&flow->napi_rx);
> +
> +err_flow:
>         for (--i; i >= 0; i--) {
>                 flow = &rx_chn->flows[i];
>                 devm_free_irq(dev, flow->irq, flow);
> ------------------------------------------------------------------------------------------------
> 
> err_request_irq => We have an extra netif_napi_add() which needs to be
> cleaned up.
> err_flow => Equal count of netif_napi_add() and devm_request_irq() that
> should be cleaned up.

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

  reply	other threads:[~2025-03-11 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 13:01 Siddharth Vadapalli
2025-03-11 13:53 ` Sverdlin, Alexander
2025-03-11 15:18   ` s-vadapalli
2025-03-11 15:25     ` Sverdlin, Alexander [this message]
2025-03-11 15:30       ` s-vadapalli

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=373ae7ef7ff20aa6dccefcb40e2312e9510132b3.camel@siemens.com \
    --to=alexander.sverdlin@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®