Skip to content

Commit 56ad91c

Browse files
Wolfram SangAndi Shyti
authored andcommitted
i2c: robotfuzz-osif: disable zero-length read messages
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: 83e53a8 ("i2c: Add bus driver for for OSIF USB i2c device.") Signed-off-by: Wolfram Sang <[email protected]> Cc: <[email protected]> # v3.14+ Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a5d0b9e commit 56ad91c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/i2c/busses/i2c-robotfuzz-osif.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ static u32 osif_func(struct i2c_adapter *adapter)
111111
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
112112
}
113113

114+
/* prevent invalid 0-length usb_control_msg */
115+
static const struct i2c_adapter_quirks osif_quirks = {
116+
.flags = I2C_AQ_NO_ZERO_LEN_READ,
117+
};
118+
114119
static const struct i2c_algorithm osif_algorithm = {
115120
.xfer = osif_xfer,
116121
.functionality = osif_func,
@@ -143,6 +148,7 @@ static int osif_probe(struct usb_interface *interface,
143148

144149
priv->adapter.owner = THIS_MODULE;
145150
priv->adapter.class = I2C_CLASS_HWMON;
151+
priv->adapter.quirks = &osif_quirks;
146152
priv->adapter.algo = &osif_algorithm;
147153
priv->adapter.algo_data = priv;
148154
snprintf(priv->adapter.name, sizeof(priv->adapter.name),

0 commit comments

Comments
 (0)