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: <20220823130702.1046-1-linkmauve@linkmauve.fr>
Date:   Tue, 23 Aug 2022 15:07:02 +0200
From:   Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
To:     Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Alessandro Zummo <a.zummo@...ertech.it>,
        linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>,
        Ash Logan <ash@...quark.com>,
        rw-r-r-0644 <r.r.qwertyuiop.r.r@...il.com>,
        Jonathan Neuschäfer <j.ne@...teo.net>
Subject: [PATCH] rtc: gamecube: Always reset HW_SRNPROT after read

This register would fail to be reset if reading the RTC bias failed for
whichever reason.  This commit reorganises the code around to
unconditionally write it back to its previous value, unmap it, and
return the result of regmap_read(), which makes it both simpler and more
correct in the error case.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
---
 drivers/rtc/rtc-gamecube.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c
index c2717bb52b2b..c828bc8e05b9 100644
--- a/drivers/rtc/rtc-gamecube.c
+++ b/drivers/rtc/rtc-gamecube.c
@@ -265,18 +265,17 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
 	 * SRAM address as on previous consoles.
 	 */
 	ret = regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
-	if (ret) {
-		pr_err("failed to get the RTC bias\n");
-		iounmap(hw_srnprot);
-		return -1;
-	}
 
 	/* Reset SRAM access to how it was before, our job here is done. */
 	if (old != 0x7bf)
 		iowrite32be(old, hw_srnprot);
+
 	iounmap(hw_srnprot);
 
-	return 0;
+	if (ret)
+		pr_err("failed to get the RTC bias\n");
+
+	return ret;
 }
 
 static const struct regmap_range rtc_rd_ranges[] = {
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ