public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Escande <nico.escande@gmail.com>
To: ath12k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, maharaja.kennadyrajan@oss.qualcomm.com
Subject: [PATCH ath-next 1/1] wifi: ath12k: avoid deadlock in thermal read
Date: Mon, 13 Apr 2026 10:38:07 +0200	[thread overview]
Message-ID: <20260413083807.1727905-2-nico.escande@gmail.com> (raw)
In-Reply-To: <20260413083807.1727905-1-nico.escande@gmail.com>

When removing the pci device we can have a deadlock if we try to read the
thermal sensor at the same time.

This is due to the fact that when the wiphy gets unregistered (so while
the wiphy lock is held), we wait for all sysfs operation to complete. But
if a read of the thermal device has been started in the mean time, we need
to acquire the wiphy lock, which will lead to a deadlock.

As we already have a flag indicating that we are currently unregistering
the device in the hw group, lets check it first (before locking) so we can
bail out early and avoid the dealock.

Signed-off-by: Nicolas Escande <nico.escande@gmail.com>
---
 drivers/net/wireless/ath/ath12k/thermal.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/thermal.c b/drivers/net/wireless/ath/ath12k/thermal.c
index a764d2112a3c..700e7458ddff 100644
--- a/drivers/net/wireless/ath/ath12k/thermal.c
+++ b/drivers/net/wireless/ath/ath12k/thermal.c
@@ -17,9 +17,13 @@ static ssize_t ath12k_thermal_temp_show(struct device *dev,
 					char *buf)
 {
 	struct ath12k *ar = dev_get_drvdata(dev);
+	struct ath12k_hw_group *ag = ath12k_ab_to_ag(ar->ab);
 	unsigned long time_left;
 	int ret, temperature;
 
+	if (!test_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags))
+		return -ESHUTDOWN;
+
 	guard(wiphy)(ath12k_ar_to_hw(ar)->wiphy);
 
 	if (ar->ah->state != ATH12K_HW_STATE_ON)
-- 
2.53.0


      reply	other threads:[~2026-04-13  8:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  8:38 [PATCH ath-next 0/1] thermal read locking problem Nicolas Escande
2026-04-13  8:38 ` Nicolas Escande [this message]

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=20260413083807.1727905-2-nico.escande@gmail.com \
    --to=nico.escande@gmail.com \
    --cc=ath12k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=maharaja.kennadyrajan@oss.qualcomm.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