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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 Aug 2022 08:27:52 +0000
From:   Eliav Farber <farbere@...zon.com>
To:     <jdelvare@...e.com>, <linux@...ck-us.net>, <robh+dt@...nel.org>,
        <mark.rutland@....com>, <linux-hwmon@...r.kernel.org>,
        <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC:     <farbere@...zon.com>, <talel@...zon.com>, <hhhawa@...zon.com>,
        <jonnyc@...zon.com>, <hanochu@...zon.com>, <ronenk@...zon.com>,
        <itamark@...zon.com>, <shellykz@...zon.com>, <shorer@...zon.com>,
        <amitlavi@...zon.com>, <almogbs@...zon.com>, <dwmw@...zon.co.uk>,
        <rtanwar@...linear.com>
Subject: [PATCH 11/16] hwmon: (mr75203) add protection for negative voltage value

This change makes sure the returned voltage vlaue is 0 or positive.

Signed-off-by: Eliav Farber <farbere@...zon.com>
---
 drivers/hwmon/mr75203.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
index 417b135c1b3f..8d8883301ff5 100644
--- a/drivers/hwmon/mr75203.c
+++ b/drivers/hwmon/mr75203.c
@@ -216,6 +216,13 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val)
 			return ret;
 
 		n &= SAMPLE_DATA_MSK;
+
+		/* Voltage can't be negative */
+		if (PVT_N_CONST * n < PVT_R_CONST) {
+			*val = 0;
+			return 0;
+		}
+
 		/* Convert the N bitstream count into voltage */
 		*val = pvt->vd[channel].pre_scaler;
 		*val *= (PVT_N_CONST * n - PVT_R_CONST);
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ