All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] power: supply: sbs-battery: Fix the shared serial number buffer
@ 2026-07-26  7:22 Babanpreet Singh
  2026-07-26  7:22 ` [PATCH 1/2] power: supply: sbs-battery: Use a per-device " Babanpreet Singh
  2026-07-26  7:22 ` [PATCH 2/2] power: supply: sbs-battery: Bound the serial number conversion to 16 bits Babanpreet Singh
  0 siblings, 2 replies; 3+ messages in thread
From: Babanpreet Singh @ 2026-07-26  7:22 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, Babanpreet Singh

The serial number of every sbs-battery instance is formatted into one
file-scope buffer, so concurrent reads on two batteries can make one
battery report the other's serial number. Patch 1 gives each device its
own buffer.

While rewriting that sprintf() call it became apparent that the
conversion is also the only W=1 warning in this driver: the value is
carried in an int and only its negative half is rejected, so gcc cannot
prove that four hex digits fit the five-byte buffer. Patch 2 casts to
the register's actual width. It is a separate patch because it is a
distinct (and purely cosmetic) change - please just drop it if you would
rather not carry it.

Both patches are compile-tested only; I have no SBS hardware. The race
in patch 1 was derived from the code, not observed on a running system.

Detail on the multi-instance premise for patch 1, since it is the part
that matters: sbs-battery binds per I2C client and sbs-manager registers
one muxed I2C channel per supported battery precisely so that the smart
battery driver can be bound to each of them (MANAGER_SBS Kconfig help
says as much), so more than one instance is a supported configuration
rather than a hypothetical one.

Babanpreet Singh (2):
  power: supply: sbs-battery: Use a per-device serial number buffer
  power: supply: sbs-battery: Bound the serial number conversion to 16
    bits

 drivers/power/supply/sbs-battery.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-26  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-26  7:22 [PATCH 0/2] power: supply: sbs-battery: Fix the shared serial number buffer Babanpreet Singh
2026-07-26  7:22 ` [PATCH 1/2] power: supply: sbs-battery: Use a per-device " Babanpreet Singh
2026-07-26  7:22 ` [PATCH 2/2] power: supply: sbs-battery: Bound the serial number conversion to 16 bits Babanpreet Singh

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.