Re: [PATCH] net: cpsw_new: unregister devlink on port registration failure

Guangshuo Li <[email protected]>
Newsgroups org.kernel.vger.linux-omap,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <CANUHTR-Z2qwdEwnG1dzfe8zH1z3hbdmGMaDNhch3oOxxA2RihQ@mail.gmail.com>
Hi,

Thank you for your review and comments.

On Thu, 4 Jun 2026 at 00:58, Sverdlin, Alexander
<[email protected]> wrote:
>
> Hi Guangshuo,
>
> On Wed, 2026-06-03 at 22:07 +0800, Guangshuo Li wrote:
> > cpsw_probe() registers devlink before registering the CPSW ports.
> >
> > If cpsw_register_ports() fails, the error path only unregisters the
> > notifiers and then releases the lower level resources. It does not undo
> > the successful cpsw_register_devlink() call, leaving the devlink instance
> > and its parameters registered after probe has failed.
> >
> > Add a devlink cleanup label for the path where devlink registration has
> > already succeeded, and use it when port registration fails.
> >
> > Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac")
> > Signed-off-by: Guangshuo Li <[email protected]>
>
> thanks for the patch! Apart from the issue Andrew mentioned, the fix itself
> looks good to me,
>
> Reviewed-by: Alexander Sverdlin <[email protected]>
>
> > ---
> >  drivers/net/ethernet/ti/cpsw_new.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
> > index 7f42f58a4b03..95b3b58db6e0 100644
> > --- a/drivers/net/ethernet/ti/cpsw_new.c
> > +++ b/drivers/net/ethernet/ti/cpsw_new.c
> > @@ -2050,7 +2050,7 @@ static int cpsw_probe(struct platform_device *pdev)
> >
> >       ret = cpsw_register_ports(cpsw);
> >       if (ret)
> > -             goto clean_unregister_notifiers;
> > +             goto clean_unregister_devlink;
> >
> >       dev_notice(dev, "initialized (regs %pa, pool size %d) hw_ver:%08X %d.%d (%d)\n",
> >                  &ss_res->start, descs_pool_size,
> > @@ -2062,6 +2062,8 @@ static int cpsw_probe(struct platform_device *pdev)
> >
> >       return 0;
> >
> > +clean_unregister_devlink:
> > +     cpsw_unregister_devlink(cpsw);
> >  clean_unregister_notifiers:
> >       cpsw_unregister_notifiers(cpsw);
> >  clean_cpts:
>
> --
> Alexander Sverdlin
> Siemens AG
> www.siemens.com
I will address Andrew's feedback and send a v2 with the subject updated
accordingly. I will also target net-next and drop the Fixes tag.

Thanks,
Guangshuo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.