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: <20191002154406.8875-1-yzhai003@ucr.edu>
Date:   Wed,  2 Oct 2019 08:44:06 -0700
From:   Yizhuo <yzhai003@....edu>
To:     unlisted-recipients:; (no To-header on input)
Cc:     csong@...ucr.edu, zhiyunq@...ucr.edu, Yizhuo <yzhai003@....edu>,
        Sebastian Reichel <sre@...nel.org>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] power: supply: max17042_battery: fix the potential uninitialized use in max17042_write_verify_reg()

In function max17042_write_verify_reg(), variable "read_value"
could be uninitialized if regmap_read() fails. However,
"read_value" is used to decide the control flow later in the if
statement, which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@....edu>
---
 drivers/power/supply/max17042_battery.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 0dfad2cf13fe..e6a2dacaa730 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -486,12 +486,15 @@ static void max17042_external_power_changed(struct power_supply *psy)
 static int max17042_write_verify_reg(struct regmap *map, u8 reg, u32 value)
 {
 	int retries = 8;
-	int ret;
+	int ret, err;
 	u32 read_value;
 
 	do {
 		ret = regmap_write(map, reg, value);
-		regmap_read(map, reg, &read_value);
+		err = regmap_read(map, reg, &read_value);
+		if (err)
+			return err;
+
 		if (read_value != value) {
 			ret = -EIO;
 			retries--;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ