On Mon, May 13, 2002, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > But, you're absolutely right about an error message being preferable to
> > a dead system. The patch is simple enough and I've attached it to the
> > bottom of this message.
>
> Well, since 0 is not an illegal value as specified in the USB spec, I
> think we should do this check in the usb_submit_urb() call, not force it
> to be duplicated in all host drivers. So how about the patch below?
>
> int usb_submit_urb(struct urb *urb, int mem_flags)
> {
> - if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op)
> +
> + if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op) {
> + if (usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) <= 0) {
> + err("%s: pipe %x has invalid size (<= 0)", __FUNCTION__, urb->pipe);
> + return -EMSGSIZE;
> + }
> return urb->dev->bus->op->submit_urb(urb, mem_flags);
> - else
> - return -ENODEV;
> + }
> + return -ENODEV;
> }
>
> Hmm. So arbitrary. Why only this single test?
> uhci_submit_urb() starts with several sanity checks.
I assume you mean uhci_submit_urb in usb-uhci, since uhci only has the 2
checks above.
The only other check I can see is:
if (urb->transfer_buffer_length < 0 && type != PIPE_ISOCHRONOUS) {
How far should we go to catch broken drivers? As it turns out, the patch
I sent appears to fix a bug that was triggered by a broken driver.
> And why precisely is it necessary?
> Why does the kernel die? Does it hang in a spinlock with
> disabled interrupts? Inspection of the code without this
> stopgap might reveal other bugs.
Yes. There's a loop which creates all of the TD's for the transfer and
since the endpoint size is 0, we never advance and we get stuck in an
infinite loop.
JE
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel