Re: [PATCH v3 1/2] usb: usbtmc: check URB actual_length for interrupt-IN notifications

From: Michal Pecio

Date: Tue May 05 2026 - 16:14:51 EST


On Tue, 5 May 2026 15:17:59 -0400, Alan Stern wrote:
> > Fix by checking if actual_data contains enough bytes for the headers,
> > otherwise resubmit URB to the interrupt endpoint.
>
> Would it be simpler to solve this by setting the two header bytes to 0
> before submitting the URB? Then if the device did not send enough data,
> the header values would be 0, which should prevent any reads from being
> out-of-bounds or getting stale data.

This amounts to saying that:
1. for 0 byte packets, the default notification type is zero
2. for 1 byte packets, the parameter byte defaults to zero

which would result in:
1. a warning (similar to this patch)
2. who knows what, why even worry about such things? ;)


If anything, I think the new warning isn't truly necessary and it
is misleading, if vendor specific notifications with zero-length
bNotify2 field are legal. It would suffice to check actual_length
before accepting the particular 2-byte long notification types,
and leave shorter packets unhandled, causing the default warning.

Another missing bit of pedantry is that these types should only be
interpreted this way on bInterfaceProtocol == 1 devices. But as
long as there are no other protocols defined (are there?), no valid
device is allowed to use them for anything else.

Regards,
Michal