mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: wan: fsl_ucc_hdlc: release the net device on remove
@ 2026-11-03 10:42 Wentao Liang
  2026-11-03 10:49 ` netdev-bot+sinfo
  2026-11-03 11:10 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:42 UTC (permalink / raw)
  To: Zhao Qiang, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linuxppc-dev, linux-kernel, Wentao Liang, stable

ucc_hdlc_probe() allocates the net device with alloc_hdlcdev() and
registers it with register_hdlc_device(), but ucc_hdlc_remove() only
tears down the QE resources and frees the private data.  The net device
is never unregistered or freed, so after the platform device is removed
or the module is unloaded it stays registered, keeps its reference to
the module and is left pointing at the freed private data.

Unregister and free the net device in ucc_hdlc_remove(), before the
private data is released, as fsl_qmc_hdlc does.

Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/wan/fsl_ucc_hdlc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 809f21fb93f5..f815cac82518 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1255,6 +1255,7 @@ static void ucc_hdlc_remove(struct platform_device *pdev)
 {
 	struct ucc_hdlc_private *priv = dev_get_drvdata(&pdev->dev);
 
+	unregister_hdlc_device(priv->ndev);
 	uhdlc_memclean(priv);
 
 	if (priv->utdm && priv->utdm->si_regs) {
@@ -1266,6 +1267,7 @@ static void ucc_hdlc_remove(struct platform_device *pdev)
 		iounmap(priv->utdm->siram);
 		priv->utdm->siram = NULL;
 	}
+	free_netdev(priv->ndev);
 	kfree(priv);
 
 	dev_info(&pdev->dev, "UCC based hdlc module removed\n");
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-03 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:42 [PATCH] net: wan: fsl_ucc_hdlc: release the net device on remove Wentao Liang
2026-11-03 10:49 ` netdev-bot+sinfo
2026-11-03 11:10 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®