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: Wed, 12 Jun 2024 18:05:54 +0000
From: Joy Chakraborty <joychakr@...gle.com>
To: Sean Anderson <sean.anderson@...o.com>, 
	Alexandre Belloni <alexandre.belloni@...tlin.com>, 
	Srinivas Kandagatla <srinivas.kandagatla@...aro.org>, Dan Carpenter <dan.carpenter@...aro.org>
Cc: linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Joy Chakraborty <joychakr@...gle.com>, stable@...r.kernel.org
Subject: [PATCH] rtc: abx80x: Fix return value of nvmem callback on read

Read callbacks registered with nvmem core expect 0 to be returned on
success and a negative value to be returned on failure.

abx80x_nvmem_xfer() on read calls i2c_smbus_read_i2c_block_data() which
returns the number of bytes read on success as per its api description,
this return value is handled as an error and returned to nvmem even on
success.

Fix to handle all possible values that would be returned by
i2c_smbus_read_i2c_block_data().

Fixes: e90ff8ede777 ("rtc: abx80x: Add nvmem support")
Cc: stable@...r.kernel.org
Signed-off-by: Joy Chakraborty <joychakr@...gle.com>
---
 drivers/rtc/rtc-abx80x.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index fde2b8054c2e..0f5847d1ca2a 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -711,9 +711,16 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset,
 		else
 			ret = i2c_smbus_read_i2c_block_data(priv->client, reg,
 							    len, val);
-		if (ret)
+		if (ret < 0)
 			return ret;
 
+		if (!write) {
+			if (ret)
+				len = ret;
+			else
+				return -EIO;
+		}
+
 		offset += len;
 		val += len;
 		bytes -= len;
-- 
2.45.2.505.gda0bf45e8d-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ