lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241208131532.1028581-1-csokas.bence@prolan.hu>
Date: Sun, 8 Dec 2024 14:15:31 +0100
From: Bence Csókás <csokas.bence@...lan.hu>
To: Sebastian Reichel <sebastian.reichel@...labora.com>,
	Csókás, Bence <csokas.bence@...lan.hu>,
	<linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Kees Bakker <kees@...erbout.nl>, Samuel Holland <samuel@...lland.org>,
	Sebastian Reichel <sre@...nel.org>
Subject: [PATCH] power: ip5xxx_power: Fix uninitialized variable read

The check for whether a charger supports the requested
battery voltage was incorrectly added to the
`ip5xxx_battery_get_voltage_max()` function, instead of
`set_voltage_max()`. This commit fixes it.

Reported-by: Kees Bakker <kees@...erbout.nl>
Closes: https://lore.kernel.org/linux-kernel/b547c228-df70-4137-9e96-175923f62404@ijzerbout.nl/
Fixes: 8584bc5df539 ("power: ip5xxx_power: Allow for more parameters to be configured")
Signed-off-by: Bence Csókás <csokas.bence@...lan.hu>
---
 drivers/power/supply/ip5xxx_power.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index 46f8eb7100c1..d076b4e46194 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
@@ -367,9 +367,6 @@ static int ip5xxx_battery_get_voltage_max(struct ip5xxx *ip5xxx, int *val)
 	if (ret)
 		return ret;
 
-	if (*val > ip5xxx->vbat_max)
-		return -EINVAL;
-
 	/*
 	 * It is not clear what this will return if
 	 * IP5XXX_CHG_CTL4_BAT_TYPE_SEL_EN is not set...
@@ -504,6 +501,9 @@ static int ip5xxx_battery_set_voltage_max(struct ip5xxx *ip5xxx, int val)
 	unsigned int rval;
 	int ret;
 
+	if (val > ip5xxx->vbat_max)
+		return -EINVAL;
+
 	switch (val) {
 	case 4200000:
 		rval = IP5XXX_BAT_TYPE_4_2V;
-- 
2.34.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ