Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: wan: fsl_ucc_hdlc: Fix potential use-after-free on removal
@ 2026-12-02 12:51 Guangshuo Li
  2026-12-03 12:54 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-12-02 12:51 UTC (permalink / raw)
  To: qiang.zhao, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: netdev, linuxppc-dev

Removal frees the HDLC private state without unregistering its network
device. The registered device retains that pointer and its operations
can access freed memory.

Unregister and free the network device before releasing its private
state and hardware resources.

This issue was found by our static analysis tool under development.

Confirmed by tracing removal and the netdev callbacks in the source.
Build-tested on powerpc with allyesconfig and allmodconfig, W=1 and
CONFIG_WERROR=n after reproducing existing baseline warnings. No
hardware, reproducer or kernel selftest runs were performed.

Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.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..5cdabe14e606 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1255,6 +1255,8 @@ static void ucc_hdlc_remove(struct platform_device *pdev)
 {
 	struct ucc_hdlc_private *priv = dev_get_drvdata(&pdev->dev);
 
+	unregister_hdlc_device(priv->ndev);
+	free_netdev(priv->ndev);
 	uhdlc_memclean(priv);
 
 	if (priv->utdm && priv->utdm->si_regs) {

base-commit: b6c8f45ed340f00bf2004d407cf7316fe3e24c48

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:51 [PATCH net] net: wan: fsl_ucc_hdlc: Fix potential use-after-free on removal Guangshuo Li
2026-12-03 12:54 ` netdev-bot+sashiko

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