On Mon, Jul 24, 2023 at 02:40:57PM +0200, Oliver Neukum wrote: > Quoting Alan Stern on why we cannot just check errors: > > The operation carried out here is deliberately unsafe (for full-speed > devices). It is made before we know the actual maxpacket size for ep0, > and as a result it might return an error code even when it works okay. > This shouldn't happen, but a lot of USB hardware is unreliable. > > Therefore we must not ignore the result merely because r < 0. If we do > that, the kernel might stop working with some devices. > > He is absolutely right. However, we must make sure that in case > we read nothing or a short answer, the buffer contains nothing > that can be misinterpreted as a valid answer. > So we have to zero it before we use it for IO. This patch is neither correct or needed. The current implementation sets buf->bMaxPacketSize0 = 0 before reading the descriptor and makes sure that that field is non-zero before accessing buf->bDescriptorType which lies before bMaxPacketSize0. It may be subtle, but it looks correct. Johan