Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Sebastian Reichel <sre@kernel.org>,
	Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 09/10] power: supply: qcom_battmgr: Hold battmgr->lock in qcom_battmgr_enable_worker()
Date: Thu,  3 Dec 2026 16:12:30 +0000	[thread overview]
Message-ID: <20261203161316.319090-10-lee@kernel.org> (raw)
In-Reply-To: <20261203161316.319090-1-lee@kernel.org>

qcom_battmgr_enable_worker() calls qcom_battmgr_request() without
acquiring battmgr->lock, racing with concurrent sysfs property queries
that also use battmgr->ack and battmgr->error and sending overlapping
requests to PMIC GLINK firmware.

Acquire battmgr->lock around qcom_battmgr_request() in
qcom_battmgr_enable_worker() and assert the lock in
qcom_battmgr_request().

Fixes: 29e8142b5623 ("power: supply: Introduce Qualcomm PMIC GLINK power supply")
Closes: https://sashiko.dev/#/bug/linux-35b68138-5485-48e9-a9ab-df314c5c19ec
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/power/supply/qcom_battmgr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 0789303a5965..4a86c3b5235c 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -351,10 +351,8 @@ static int qcom_battmgr_request(struct qcom_battmgr *battmgr, void *data, size_t
 	unsigned long left;
 	int ret;
 
-	/*
-	 * Callers hold @lock, except enable_work, which is disabled before
-	 * client_gone is set.
-	 */
+	lockdep_assert_held(&battmgr->lock);
+
 	if (battmgr->client_gone)
 		return -ENODEV;
 
@@ -1748,7 +1746,9 @@ static void qcom_battmgr_enable_worker(struct work_struct *work)
 	};
 	int ret;
 
+	mutex_lock(&battmgr->lock);
 	ret = qcom_battmgr_request(battmgr, &req, sizeof(req));
+	mutex_unlock(&battmgr->lock);
 	if (ret)
 		dev_err(battmgr->dev, "failed to request power notifications\n");
 }
-- 
2.56.1.911.g883d8bcb20-goog


      reply	other threads:[~2026-12-03 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:12 [PATCH 00/10] power: supply: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 16:12 ` Lee Jones [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=20261203161316.319090-10-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=bjorn.andersson@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sre@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