[PATCH 08/10] power: supply: cpcap-battery: Release battery info in cpcap_battery_update_battery_data()
From: Lee Jones
Date: Thu Dec 03 2026 - 11:14:28 EST
cpcap_battery_update_battery_data() allocates battery info via
power_supply_get_battery_info(), copies five integer fields, and
returns without calling power_supply_put_battery_info(). When the
nvmem device is absent, repeated sysfs reads invoke this helper and
continuously leak devres allocations.
Release the temporary battery info via power_supply_put_battery_info()
before returning.
Fixes: f0c8407c83a5 ("power: supply: cpcap-battery: pass static battery cell data from device tree")
Closes: https://sashiko.dev/#/bug/linux-02b35419-d9a3-425a-9d0f-1b01b1ec2adc
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/power/supply/cpcap-battery.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 808714c6ce95..1981d52a3ed8 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -426,6 +426,8 @@ static void cpcap_battery_update_battery_data(struct cpcap_battery_ddata *ddata)
if (info->constant_charge_voltage_max_uv > 0)
ddata->config.bat.constant_charge_voltage_max_uv =
info->constant_charge_voltage_max_uv;
+
+ power_supply_put_battery_info(ddata->psy, info);
}
static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata)
--
2.56.1.911.g883d8bcb20-goog