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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 19 May 2022 12:50:19 +0000
From:   Adam Wujek <dev_public@...ek.eu>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Adam Wujek <dev_public@...ek.eu>,
        Michal Simek <michal.simek@...inx.com>,
        linux-arm-kernel@...ts.infradead.org, linux-i2c@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] i2c: busses: i2c-cadence: fix message length when receive block message

Needed by hwmon/pmbus_core driver to correctly calculate PEC.
The hwmon/pmbus_core driver relies on bus drivers to update the message length
of received block transfers. Only in this type of smbus transfer, in which the
length is not known before the transfer is started.

Signed-off-by: Adam Wujek <dev_public@...ek.eu>
---
 drivers/i2c/busses/i2c-cadence.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 20ac432a37ea..65f1979d4e6f 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -830,6 +830,11 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
 		return -ETIMEDOUT;
 	}

+	/* Update message len, as i2c/smbus driver (function
+	 * i2c_smbus_xfer_emulated) relies on i2c device drivers to do this */
+	if ((msg->flags & I2C_M_RECV_LEN) && (msg->flags & I2C_M_RD))
+		msg->len = msg->buf[0] + 2; /* add len byte + PEC byte */
+
 	cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
 			  CDNS_I2C_IDR_OFFSET);

--
2.17.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ