public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: robotfuzz-osif: disable zero-length read messages
@ 2025-05-22  6:42 Wolfram Sang
  2025-05-22  6:57 ` Wolfram Sang
  2025-06-25 20:52 ` Andi Shyti
  0 siblings, 2 replies; 3+ messages in thread
From: Wolfram Sang @ 2025-05-22  6:42 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alan Stern, Nikita Zhandarovich, Wolfram Sang, Andi Shyti

This driver passes the length of an i2c_msg directly to
usb_control_msg(). If the message is now a read and of length 0, it
violates the USB protocol and a warning will be printed. Enable the
I2C_AQ_NO_ZERO_LEN_READ quirk for this adapter thus forbidding 0-length
read messages altogether.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-robotfuzz-osif.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i2c/busses/i2c-robotfuzz-osif.c b/drivers/i2c/busses/i2c-robotfuzz-osif.c
index 80d45079b763..e0a76fb5bc31 100644
--- a/drivers/i2c/busses/i2c-robotfuzz-osif.c
+++ b/drivers/i2c/busses/i2c-robotfuzz-osif.c
@@ -111,6 +111,11 @@ static u32 osif_func(struct i2c_adapter *adapter)
 	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
+/* prevent invalid 0-length usb_control_msg */
+static const struct i2c_adapter_quirks osif_quirks = {
+	.flags = I2C_AQ_NO_ZERO_LEN_READ,
+};
+
 static const struct i2c_algorithm osif_algorithm = {
 	.xfer = osif_xfer,
 	.functionality = osif_func,
@@ -143,6 +148,7 @@ static int osif_probe(struct usb_interface *interface,
 
 	priv->adapter.owner = THIS_MODULE;
 	priv->adapter.class = I2C_CLASS_HWMON;
+	priv->adapter.quirks = &osif_quirks;
 	priv->adapter.algo = &osif_algorithm;
 	priv->adapter.algo_data = priv;
 	snprintf(priv->adapter.name, sizeof(priv->adapter.name),
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: robotfuzz-osif: disable zero-length read messages
  2025-05-22  6:42 [PATCH] i2c: robotfuzz-osif: disable zero-length read messages Wolfram Sang
@ 2025-05-22  6:57 ` Wolfram Sang
  2025-06-25 20:52 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2025-05-22  6:57 UTC (permalink / raw)
  To: linux-i2c; +Cc: Alan Stern, Nikita Zhandarovich, Andi Shyti

[-- Attachment #1: Type: text/plain, Size: 516 bytes --]

On Thu, May 22, 2025 at 08:42:35AM +0200, Wolfram Sang wrote:
> This driver passes the length of an i2c_msg directly to
> usb_control_msg(). If the message is now a read and of length 0, it
> violates the USB protocol and a warning will be printed. Enable the
> I2C_AQ_NO_ZERO_LEN_READ quirk for this adapter thus forbidding 0-length
> read messages altogether.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Fixes: 83e53a8f120f ("i2c: Add bus driver for for OSIF USB i2c device.")


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: robotfuzz-osif: disable zero-length read messages
  2025-05-22  6:42 [PATCH] i2c: robotfuzz-osif: disable zero-length read messages Wolfram Sang
  2025-05-22  6:57 ` Wolfram Sang
@ 2025-06-25 20:52 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2025-06-25 20:52 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Alan Stern, Nikita Zhandarovich

Hi Wolfram,

On Thu, May 22, 2025 at 08:42:35AM +0200, Wolfram Sang wrote:
> This driver passes the length of an i2c_msg directly to
> usb_control_msg(). If the message is now a read and of length 0, it
> violates the USB protocol and a warning will be printed. Enable the
> I2C_AQ_NO_ZERO_LEN_READ quirk for this adapter thus forbidding 0-length
> read messages altogether.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

sorry for the delay, together with the tiny usb fixe, merged in
i2c/i2c-host-next.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-25 20:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22  6:42 [PATCH] i2c: robotfuzz-osif: disable zero-length read messages Wolfram Sang
2025-05-22  6:57 ` Wolfram Sang
2025-06-25 20:52 ` Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox