Op 19-11-2024 om 19:07 schreef Csókás, Bence:
Other parts such as IP5306 may support other battery voltages andThis is introducing the read of an uninitialized variable.
have different constants for input voltage regulation. Allow these
to be passed from `struct ip5xxx_regfield_config`.
Signed-off-by: Csókás, Bence <csokas.bence@xxxxxxxxx>
---
drivers/power/supply/ip5xxx_power.c | 43 ++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index 41d91504eb32..a939dbfe8d23 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
[...]
/*
@@ -328,6 +348,9 @@ static int ip5xxx_battery_get_voltage_max(struct ip5xxx *ip5xxx, int *val)
if (ret)
return ret;
+ if (*val > ip5xxx->vbat_max)
+ return -EINVAL;
You have to check all the callers of ip5xxx_battery_get_voltage_max()
and what variable *val is pointing to. For example in
ip5xxx_battery_get_property() the variable vmax is not initialized,
while its address is passed to ip5xxx_battery_get_voltage_max()
But maybe the intention was to check rval instead of *val?
[...]