Executive brief
The MAX17040 fuel gauge driver in the Linux kernel failed to properly handle I2C communication errors when reading battery voltage and state-of-charge values. When these hardware register reads failed, the driver would report uninitialized (bogus) values to userspace and potentially emit false battery status change events. This fix ensures errors are properly propagated so applications receive reliable battery information.
Technical details
The max17040_get_vcell() and max17040_get_soc() functions in drivers/power/supply/max17040_battery.c ignored error returns from regmap_read() calls. When I2C transfers failed, uninitialized register values were silently converted and reported to userspace as valid voltage or state-of-charge readings. The polling worker could also replace cached values with bogus data and emit spurious change events. The fix wraps regmap_read() calls with explicit error checking, propagates errors through the power_supply get_property callback, and preserves the last valid cached state-of-charge when polling fails. The patch was applied across stable kernel branches from 2.6.11 through 7.2.
Affected products
- Linux Linux kernel multiple (see stable branches 2.6.11 through 7.2)
Timeline
- 2026-07-27: disclosed
- 2026-09-07: patched