Linux CAN drivers development
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol@kernel.org>
To: Haoxiang Li <haoxiang_li2024@163.com>, mkl@pengutronix.de
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH] can: etas_es58x: fix devlink leak on probe failure
Date: Sat, 28 Nov 2026 16:12:09 +0100	[thread overview]
Message-ID: <fe075533-2dc6-44c3-8226-491aedc21866@kernel.org> (raw)
In-Reply-To: <20261128135423.1298105-1-haoxiang_li2024@163.com>

On 28/11/2026 at 14:54, Haoxiang Li wrote:
> If es58x_init_netdev() fails, es58x_probe() frees the CAN network
> devices but leaves the devlink instance registered and allocated.
> Unregister the devlink instance before removing its ports, then free
> it and clear the interface data before returning the probe error.
> 
> Fixes: 2c4a1efcf6ab ("can: etas_es58x: add devlink support")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>  drivers/net/can/usb/etas_es58x/es58x_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
> index e1724ae79c5a..36ec4cd87434 100644
> --- a/drivers/net/can/usb/etas_es58x/es58x_core.c
> +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
> @@ -2238,7 +2238,10 @@ static int es58x_probe(struct usb_interface *intf,
>  		int ret = es58x_init_netdev(es58x_dev, ch_idx);
>  
>  		if (ret) {
> +			devlink_unregister(priv_to_devlink(es58x_dev));
>  			es58x_free_netdevs(es58x_dev);
> +			devlink_free(priv_to_devlink(es58x_dev));
> +			usb_set_intfdata(intf, NULL);
>  			return ret;
>  		}
>  	}

The fix looks correct, but with this, the if branch looks nearly
identical to es58x_disconnect(). Couldn't the clean-up logic be
factorized in one location? For example by moving those three lines:

	devlink_unregister(priv_to_devlink(es58x_dev));
	devlink_free(priv_to_devlink(es58x_dev));
	usb_set_intfdata(intf, NULL);

from es58x_disconnect() to es58x_free_netdevs()?


Yours sincerely,
Vincent Mailhol


      reply	other threads:[~2026-11-28 15:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 13:54 [PATCH] can: etas_es58x: fix devlink leak on probe failure Haoxiang Li
2026-11-28 15:12 ` Vincent Mailhol [this message]

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=fe075533-2dc6-44c3-8226-491aedc21866@kernel.org \
    --to=mailhol@kernel.org \
    --cc=haoxiang_li2024@163.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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