Netdev List
 help / color / mirror / Atom feed
From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: qiang.zhao@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH net] net: wan: fsl_ucc_hdlc: Fix potential use-after-free on removal
Date: Wed,  2 Dec 2026 20:51:34 +0800	[thread overview]
Message-ID: <20261202-19c6929445-net-wan@mail.sdu.edu.cn> (raw)

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

             reply	other threads:[~2026-12-02 12:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:51 Guangshuo Li [this message]
2026-12-03 12:54 ` [PATCH net] net: wan: fsl_ucc_hdlc: Fix potential use-after-free on removal netdev-bot+sashiko

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=20261202-19c6929445-net-wan@mail.sdu.edu.cn \
    --to=liguangshuo@mail.sdu.edu.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qiang.zhao@nxp.com \
    /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