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]
Date:   Fri,  4 Oct 2019 11:52:06 -0700
From:   Yizhuo <yzhai003@....edu>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Yizhuo <yzhai003@....edu>, Alessandro Zummo <a.zummo@...ertech.it>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] rtc: snvs: fix uninitialized usage of "lpcr" in snvs_rtc_enable()

Inside function snvs_rtc_enable(), variable "lpcr" could be
uninitialized if regmap_read() returns -EINVAL. However,"lpcr"
is used later in the if statement, which is potentially unsafe.

Similar cases happened in function snvs_rtc_irq_handler() with
variable "lpsr" and function snvs_rtc_read_alarm() with variables
"lptar", "lpsr". The patch for those two are not easy since
-EINVAL is not an acceptable return value for these functions.

Signed-off-by: Yizhuo <yzhai003@....edu>
---
 drivers/rtc/rtc-snvs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index 757f4daa7181..dadcc3e193b2 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -124,12 +124,16 @@ static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
 {
 	int timeout = 1000;
 	u32 lpcr;
+	int ret;
 
 	regmap_update_bits(data->regmap, data->offset + SNVS_LPCR, SNVS_LPCR_SRTC_ENV,
 			   enable ? SNVS_LPCR_SRTC_ENV : 0);
 
 	while (--timeout) {
-		regmap_read(data->regmap, data->offset + SNVS_LPCR, &lpcr);
+		ret = regmap_read(data->regmap,
+					data->offset + SNVS_LPCR, &lpcr);
+		if (ret)
+			return ret;
 
 		if (enable) {
 			if (lpcr & SNVS_LPCR_SRTC_ENV)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ