Linux wireless drivers development
 help / color / mirror / Atom feed
From: Andrei-Alexandru Bleortu <me@andrei-z.com>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: <ath11k@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<linux-wireless@vger.kernel.org>
Subject: [PATCH] wifi: ath11k: fix NULL dereference in pci remove when QMI init incomplete
Date: Fri, 2 Oct 2026 15:19:08 +0300	[thread overview]
Message-ID: <20261002121909.994262-1-me@andrei-z.com> (raw)

If QMI messages never arrive (for example when qrtr_mhi is not
loaded), WLAN initialization stops before the device is registered.
In this case ATH11K_FLAG_QMI_FAIL is not set because no QMI event
handler is executed, and ATH11K_FLAG_REGISTERED is not set either.

When the driver is removed, ath11k_pci_remove() still calls
ath11k_core_deinit(), which eventually triggers
ath11k_ce_cleanup_pipes() on uninitialized CE pipes and results in a
NULL pointer dereference in ath11k_hal_srng_access_begin():

  ath11k_hal_srng_access_begin+0xc/0x60 [ath11k]
  ath11k_ce_cleanup_pipes+0x16c/0x170 [ath11k]
  ath11k_pcic_stop+0x20/0x3c [ath11k]
  ath11k_core_stop+0x30/0x58 [ath11k]
  ath11k_core_deinit+0xf8/0x1b8 [ath11k]
  ath11k_pci_remove+0x74/0x140 [ath11k_pci]

Fix this by also taking the QMI failure path in ath11k_pci_remove()
when ATH11K_FLAG_REGISTERED is not set: core initialization did not
complete, so ath11k_core_deinit() is unsafe. This is the PCI
counterpart of commit 1a7bcf5324c8 ("wifi: ath11k: fix NULL
dereference in ahb remove when QMI init incomplete").

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1

Fixes: 6fbd8898b301 ("ath11k: pci: fix rmmod crash")
Assisted-by: LLM
Signed-off-by: Andrei-Alexandru Bleortu <me@andrei-z.com>
---
Found and fixed with an AI coding assistant (Claude Code), which also
drafted this changelog. The crash was reproduced on a Ubiquiti UniFi U6
Enterprise (IPQ5018 + 2x QCN9074) running 7.2.8 with the OpenWrt
backports ath11k: with qrtr_mhi withheld, rmmod ath11k_pci oopses as
above without this change and is clean with it. On ath-next the patch
is compile-tested (W=1) only.

 drivers/net/wireless/ath/ath11k/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c
index a163168f3617..1de8ccb02487 100644
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -1181,7 +1181,8 @@ static void ath11k_pci_remove(struct pci_dev *pdev)
 
 	ath11k_pci_set_irq_affinity_hint(ab_pci, NULL);
 
-	if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) {
+	if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags) ||
+	    !test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) {
 		ath11k_pci_power_down(ab, false);
 		ath11k_debugfs_soc_destroy(ab);
 		ath11k_qmi_deinit_service(ab);
-- 
2.47.3



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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261002121909.994262-1-me@andrei-z.com \
    --to=me@andrei-z.com \
    --cc=ath11k@lists.infradead.org \
    --cc=jjohnson@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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