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: <redacted>
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <redacted>
---
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