power: supply: sbs-battery: Fix the shared serial number buffer
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | power: supply: sbs-battery: Use a per-device serial number bufferdrivers/ | +4 | 0 replies | |
| 2/2 | power: supply: sbs-battery: Bound the serial number conversion to 16 bitsdrivers/ | +1 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] power: supply: sbs-battery: Fix the shared serial number buffer
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(-)
Signature · 1 line
2.43.0