* [PATCH] can: etas_es58x: fix devlink leak on probe failure
@ 2026-11-28 13:54 Haoxiang Li
2026-11-28 15:12 ` Vincent Mailhol
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-11-28 13:54 UTC (permalink / raw)
To: mailhol, mkl; +Cc: linux-can, Haoxiang Li
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;
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: etas_es58x: fix devlink leak on probe failure
2026-11-28 13:54 [PATCH] can: etas_es58x: fix devlink leak on probe failure Haoxiang Li
@ 2026-11-28 15:12 ` Vincent Mailhol
0 siblings, 0 replies; 2+ messages in thread
From: Vincent Mailhol @ 2026-11-28 15:12 UTC (permalink / raw)
To: Haoxiang Li, mkl; +Cc: linux-can
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 15:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox