Re: [PATCH net v2] net: ethernet: ti: am65-cpsw: Fix NAPI registration sequence

From: s-vadapalli@xxxxxx
Date: Tue Mar 11 2025 - 11:37:10 EST


On Tue, Mar 11, 2025 at 03:25:36PM +0000, Sverdlin, Alexander wrote:
> Hi Siddharth!
>
> On Tue, 2025-03-11 at 20:48 +0530, s-vadapalli@xxxxxx 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@xxxxxx>
> > > > Co-developed-by: Siddharth Vadapalli <s-vadapalli@xxxxxx>
> > > > Signed-off-by: Siddharth Vadapalli <s-vadapalli@xxxxxx>
> > >
> > > ...
> > >
> > >
> > > > @@ -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!

Thank you for the confirmation. I will post the v3 patch with the fix.

Regards,
Siddharth.