Skip to content

Commit f94a7d2

Browse files
author
Desnes Nunes
committed
i2c: tiny-usb: disable zero-length read messages
JIRA: https://issues.redhat.com/browse/RHEL-116007 commit cbdb25c Author: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: Thu, 22 May 2025 08:43:49 +0200 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. Fixes: e8c76ee ("i2c: New i2c-tiny-usb bus driver") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Cc: <stable@vger.kernel.org> # v2.6.22+ Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250522064349.3823-2-wsa+renesas@sang-engineering.com Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 7f6908a commit f94a7d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/i2c/busses/i2c-tiny-usb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ static u32 usb_func(struct i2c_adapter *adapter)
139139
return ret;
140140
}
141141

142+
/* prevent invalid 0-length usb_control_msg */
143+
static const struct i2c_adapter_quirks usb_quirks = {
144+
.flags = I2C_AQ_NO_ZERO_LEN_READ,
145+
};
146+
142147
/* This is the actual algorithm we define */
143148
static const struct i2c_algorithm usb_algorithm = {
144149
.xfer = usb_xfer,
@@ -247,6 +252,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
247252
/* setup i2c adapter description */
248253
dev->adapter.owner = THIS_MODULE;
249254
dev->adapter.class = I2C_CLASS_HWMON;
255+
dev->adapter.quirks = &usb_quirks;
250256
dev->adapter.algo = &usb_algorithm;
251257
dev->adapter.algo_data = dev;
252258
snprintf(dev->adapter.name, sizeof(dev->adapter.name),

0 commit comments

Comments
 (0)