From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Rong Zhang <i@rong.moe>,
Avraham Hollander <anhollander516@gmail.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 7.2.y 1/2] ACPI: battery: Use kstrtoul() over sscanf("%lu\n")
Date: Mon, 7 Sep 2026 21:38:22 -0400 [thread overview]
Message-ID: <20260908013823.1787474-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090357-tweet-veal-37b7@gregkh>
From: Rong Zhang <i@rong.moe>
[ Upstream commit 57346c4d78d38b357dbe9ef16d3f63bf4610c039 ]
It is more preferred to use kstrto*() to parse a single number. The
function family properly returns an errno on error and is the correct
mechanism to parse data from sysfs.
The number base is set to 10 in order not to break the ABI.
Tested-by: Avraham Hollander <anhollander516@gmail.com>
Signed-off-by: Rong Zhang <i@rong.moe>
Link: https://patch.msgid.link/20260718-b4-acpi-battery-notification-v4-2-599c8ed1072f@rong.moe
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Stable-dep-of: 9e409f1dff78 ("ACPI: battery: Protect all properties with a separated mutex")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/acpi/battery.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index f5e0eb299610b..605c47efdf06b 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -668,9 +668,13 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
{
unsigned long x;
struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
+ int err;
- if (sscanf(buf, "%lu\n", &x) == 1)
- battery->alarm = x/1000;
+ err = kstrtoul(buf, 10, &x);
+ if (err)
+ return err;
+
+ battery->alarm = x / 1000;
if (acpi_battery_present(battery))
acpi_battery_set_alarm(battery);
return count;
--
2.53.0
next prev parent reply other threads:[~2026-09-08 1:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 13:43 FAILED: patch "[PATCH] ACPI: battery: Protect all properties with a separated mutex" failed to apply to 7.2-stable tree gregkh
2026-09-08 1:38 ` Sasha Levin [this message]
2026-09-08 1:38 ` [PATCH 7.2.y 2/2] ACPI: battery: Protect all properties with a separated mutex Sasha Levin
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=20260908013823.1787474-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=anhollander516@gmail.com \
--cc=i@rong.moe \
--cc=rafael.j.wysocki@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.