From: Hongyan Xu <getshell@seu.edu.cn>
To: toke@toke.dk, afaerber@suse.de, mani@kernel.org
Cc: Hongyan Xu <getshell@seu.edu.cn>,
linux-wireless@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: [PATCH RESEND] wifi: ath9k: stop using owl context after completion
Date: Tue, 28 Jul 2026 21:34:46 +0800 [thread overview]
Message-ID: <20260728133446.692-1-getshell@seu.edu.cn> (raw)
owl_remove() waits for eeprom_load, but both owl_fw_cb() and
owl_nvmem_work() completed it before their last uses of ctx. The
devm-allocated context can therefore be freed while the async path still
dereferences it.
Take a pci_dev reference and copy ctx-owned pointers while ctx is still
protected. Complete only after ctx is no longer needed.
Keep the completion before owl_rescan(). Rescan can remove the device
synchronously.
This issue was found by a static analysis tool.
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
Resend with Manivannan's current address. No code changes.
.../wireless/ath/ath9k/ath9k_pci_owl_loader.c | 31 ++++++++++++-------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c b/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c
index fe1013a3a..1aefe21d2 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c
+++ b/drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c
@@ -125,16 +125,19 @@ static void owl_rescan(struct pci_dev *pdev)
static void owl_fw_cb(const struct firmware *fw, void *context)
{
struct owl_ctx *ctx = context;
-
- complete(&ctx->eeprom_load);
+ struct pci_dev *pdev = pci_dev_get(ctx->pdev);
if (fw) {
- ath9k_pci_fixup(ctx->pdev, (const u16 *)fw->data, fw->size);
- owl_rescan(ctx->pdev);
+ ath9k_pci_fixup(pdev, (const u16 *)fw->data, fw->size);
+ release_firmware(fw);
+ complete(&ctx->eeprom_load);
+ owl_rescan(pdev);
} else {
- dev_err(&ctx->pdev->dev, "no eeprom data received.\n");
+ dev_err(&pdev->dev, "no eeprom data received.\n");
+ complete(&ctx->eeprom_load);
}
- release_firmware(fw);
+
+ pci_dev_put(pdev);
}
static const char *owl_get_eeprom_name(struct pci_dev *pdev)
@@ -158,19 +161,23 @@ static const char *owl_get_eeprom_name(struct pci_dev *pdev)
static void owl_nvmem_work(struct work_struct *work)
{
struct owl_ctx *ctx = container_of(work, struct owl_ctx, work);
+ struct pci_dev *pdev = pci_dev_get(ctx->pdev);
+ struct nvmem_cell *cell = ctx->cell;
void *buf;
size_t len;
- complete(&ctx->eeprom_load);
-
- buf = nvmem_cell_read(ctx->cell, &len);
+ buf = nvmem_cell_read(cell, &len);
if (!IS_ERR(buf)) {
- ath9k_pci_fixup(ctx->pdev, buf, len);
+ ath9k_pci_fixup(pdev, buf, len);
kfree(buf);
- owl_rescan(ctx->pdev);
+ complete(&ctx->eeprom_load);
+ owl_rescan(pdev);
} else {
- dev_err(&ctx->pdev->dev, "no nvmem data received.\n");
+ dev_err(&pdev->dev, "no nvmem data received.\n");
+ complete(&ctx->eeprom_load);
}
+
+ pci_dev_put(pdev);
}
static int owl_nvmem_probe(struct owl_ctx *ctx)
--
2.50.1.windows.1
reply other threads:[~2026-07-28 13:34 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=20260728133446.692-1-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=afaerber@suse.de \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mani@kernel.org \
--cc=toke@toke.dk \
/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