From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Alexandre Belloni <alexandre.belloni@bootlin.com>,
Adriana Stancu <adriana@arista.com>, Pavel Machek <pavel@denx.de>,
Piotr Ziecik <kosmo@semihalf.com>,
Enric Balletbo i Serra <eballetbo@kernel.org>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 10/10] rtc: bq32k: use u8 register buffer in trickle_charge_bypass sysfs
Date: Mon, 23 Nov 2026 19:59:21 +0000 [thread overview]
Message-ID: <20261123200012.502284-11-lee@kernel.org> (raw)
In-Reply-To: <20261123200012.502284-1-lee@kernel.org>
bq32k_sysfs_show_tricklecharge_bypass() and
bq32k_sysfs_store_tricklecharge_bypass() pass an uninitialised int to
1-byte bq32k_read() and bq32k_write() transfers. This leaves three
bytes of reg uninitialised on the stack, and on big-endian systems
populates the most significant byte while bitwise operations with
BQ32K_TCFE inspect and modify the uninitialised least significant byte,
leaking a bit of stack memory on reads and failing to update the
hardware register on writes.
Declare reg as u8 in both callbacks.
Fixes: 4c466872d8ae ("rtc: bq32000: add support to enable disable the trickle charge FET bypass")
Closes: https://sashiko.dev/#/bug/linux-1ab3635e-98ec-4ca3-a4d3-58033a48c44d
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/rtc/rtc-bq32k.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 0f50cfce88cb..7e5080eeee3a 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -204,7 +204,8 @@ static ssize_t bq32k_sysfs_show_tricklecharge_bypass(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- int reg, error;
+ u8 reg;
+ int error;
error = bq32k_read(dev, ®, BQ32K_CFG2, 1);
if (error)
@@ -217,7 +218,8 @@ static ssize_t bq32k_sysfs_store_tricklecharge_bypass(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- int reg, enable, error;
+ int enable, error;
+ u8 reg;
if (kstrtoint(buf, 0, &enable))
return -EINVAL;
--
2.56.1.750.gf70dc682cf-goog
prev parent reply other threads:[~2026-11-23 20:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261123200012.502284-1-lee@kernel.org>
2026-11-23 19:59 ` [PATCH 01/10] rtc: rx8025: pass parent I2C device in clock_adjust_ppb sysfs callbacks Lee Jones
2026-11-23 19:59 ` [PATCH 02/10] rtc: mt6397: handle non-DT platform device matching in probe Lee Jones
2026-11-23 19:59 ` [PATCH 03/10] rtc: ma35d1: allocate RTC device before requesting interrupt Lee Jones
2026-11-23 19:59 ` [PATCH 04/10] rtc: mpc5121: get interrupts via platform_get_irq() Lee Jones
2026-11-23 19:59 ` [PATCH 05/10] rtc: m41t80: use devm helpers for square-wave clock registration Lee Jones
2026-11-23 19:59 ` [PATCH 06/10] rtc: nct3018y: fix clock provider use-after-free and leak on unbind Lee Jones
2026-11-23 19:59 ` [PATCH 07/10] rtc: stmp3xxx: unregister child watchdog platform device " Lee Jones
2026-11-23 19:59 ` [PATCH 08/10] rtc: ds1685: check driver data for NULL in ds1685_rtc_poweroff() Lee Jones
2026-11-23 19:59 ` [PATCH 09/10] rtc: omap: prevent NULL and dangling pointer dereferences in power-off path Lee Jones
2026-11-23 19:59 ` 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=20261123200012.502284-11-lee@kernel.org \
--to=lee@kernel.org \
--cc=adriana@arista.com \
--cc=alexandre.belloni@bootlin.com \
--cc=eballetbo@kernel.org \
--cc=kosmo@semihalf.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=pavel@denx.de \
--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