Re: [PATCH v2 resend] media: dvb: usb: Fix WARNING in dib0700_i2c_xfer/usb_submit_urb

From: Alan Stern
Date: Fri Mar 28 2025 - 22:09:08 EST


On Fri, Mar 28, 2025 at 04:45:10PM +0100, Wolfram Sang wrote:
> Alan,
>
> > Fix the problem by adding the I2C_AQ_NO_ZERO_LEN_READ adapter quirk
> > flag to all the USB I2C adapter devices managed by dvb-usb-i2c.c,
> > following Wolfram Sang's suggestion. This tells the I2C core not to
> > allow length-0 read messages.
>
> Thank you again for fixing this issue. There are some USB-I2C bridges in
> drivers/i2c/busses which also do not prevent zero len reads. Would it
> make sense to put a protection into the I2C core? Can we reliably detect
> that an adapter sits on a USB (maybe via the parent device), so that we
> can then check if I2C_AQ_NO_ZERO_LEN_READ is set, and take action if
> not?

This really should be handled by someone who knows how those bridges
work.

In the case of dib0700, it was clear from the source code that the
driver uses USB Control transfers to tell the hardware about I2C
messages. I don't know if other bridges work in the same way. In
theory a bridge could use USB Bulk transfers instead; they aren't
subject to this restriction on length-0 reads. Or a bridge could use a
Control read transfer but include extra header material along with the
actual data, so that a length-0 message wouldn't end up generating a
length-0 read.

So the short answer is that you would need to find someone who really
understands what's going on here -- which I don't. Sorry.

Alan Stern