From: Soeren Coremans <sorencoremans@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: arend.vanspriel@broadcom.com, brcm80211@lists.linux.dev,
brcm80211-dev-list.pdl@broadcom.com,
Soeren Coremans <sorencoremans@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH wireless-next 1/3] wifi: brcmfmac: pcie: stop console read on invalid write index
Date: Thu, 5 Nov 2026 22:59:52 +0100 [thread overview]
Message-ID: <20261105215954.184290-2-sorencoremans@gmail.com> (raw)
In-Reply-To: <20261105215954.184290-1-sorencoremans@gmail.com>
When the device drops off the bus, MMIO reads return all ones. The
console write index then never matches read_idx, which wraps at
bufsize, so brcmf_pcie_bus_console_read() loops forever and floods the
kernel log with 0xff characters at several thousand lines per second.
Seen on a BCM4366 after a firmware trap followed by a fatal PCIe error
(FCP): the reset path and the failed dongle setup both entered the loop
and never reached device_release_driver().
Return early when the write index lies outside the console buffer.
Found and written with the help of an AI coding assistant (Claude Opus
5.5); the cover letter describes how.
Fixes: 9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")
Cc: stable@vger.kernel.org
Signed-off-by: Soeren Coremans <sorencoremans@gmail.com>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index eca5f5f63bce..02c58de67b82 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -992,6 +992,14 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,
return;
addr = console->base_addr + BRCMF_CONSOLE_WRITEIDX_OFFSET;
newidx = brcmf_pcie_read_tcm32(devinfo, addr);
+ /* A dead device reads back as all ones, an index read_idx never
+ * reaches; without this check the loop below never terminates.
+ */
+ if (newidx >= console->bufsize) {
+ brcmf_dbg(PCIE, "invalid console write index %u (bufsize %u)\n",
+ newidx, console->bufsize);
+ return;
+ }
while (newidx != console->read_idx) {
addr = console->buf_addr + console->read_idx;
ch = brcmf_pcie_read_tcm8(devinfo, addr);
--
2.53.0
parent reply other threads:[~2026-11-05 22:00 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261105215954.184290-1-sorencoremans@gmail.com>]
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=20261105215954.184290-2-sorencoremans@gmail.com \
--to=sorencoremans@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=linux-wireless@vger.kernel.org \
--cc=stable@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