RE: [PATCH net-next v4 11/13] net: renesas: rswitch: add passing of rswitch_private into notifiers

From: Michael Dege

Date: Fri May 22 2026 - 07:23:25 EST


Hello Jakub,

Thank you for your review.

> -----Original Message-----
> From: Jakub Kicinski <kuba@xxxxxxxxxx>
> Sent: Wednesday, May 13, 2026 3:36 AM
> To: Michael Dege <michael.dege@xxxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>; Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>;
> andrew+netdev@xxxxxxx; davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; pabeni@xxxxxxxxxx; niklas.soderlund
> <niklas.soderlund@xxxxxxxxxxxx>; paul@xxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-renesas-
> soc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH net-next v4 11/13] net: renesas: rswitch: add passing of rswitch_private into
> notifiers
>
> This is an AI-generated review of your patch. The human sending this email has considered the AI
> review valid, or at least plausible.
> ---
> net: renesas: rswitch: add passing of rswitch_private into notifiers
>
> This commit updates the notifier registration functions to accept a pointer to the rswitch_private
> structure, allowing the handlers to access the hardware.
>
> > diff --git a/drivers/net/ethernet/renesas/rswitch_main.c
> > b/drivers/net/ethernet/renesas/rswitch_main.c
> > --- a/drivers/net/ethernet/renesas/rswitch_main.c
> > +++ b/drivers/net/ethernet/renesas/rswitch_main.c
> [ ... ]
> > @@ -2290,7 +2290,7 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
> > if (list_empty(&priv->port_list))
> > dev_warn(&pdev->dev, "could not initialize any ports\n");
> >
> > - ret = rswitch_register_notifiers();
> > + ret = rswitch_register_notifiers(priv);
> > if (ret) {
> > dev_err(&pdev->dev, "could not register notifiers\n");
> > return ret;
>
> If rswitch_register_notifiers() fails here, does this error path skip cleaning up the initialization
> performed earlier by rswitch_init()?
>
> It looks like rswitch_init() registers network devices, but this error path returns directly without
> calling rswitch_deinit() or the runtime PM puts.
>
> Since priv is allocated using devm_kzalloc, the memory will be automatically freed when the probe
> fails. Could this result in a use-after-free if those dangling network interfaces are subsequently
> brought up or receive packets?

I have reworked the error path, now rswitch_deinit is called and the runtime PM puts are also called.

Best regards,

Michael