Re: [PATCH 1/2] usb hcd: poll hcd device to force writes

From: Alan Stern
Date: Tue May 12 2009 - 22:26:18 EST


On Tue, 12 May 2009, Jason Wessel wrote:

> This patch takes the route of forcibly polling the hcd device to drain
> the urb queue in order to initiate the bulk write call backs. This
> only happens if the device is a usb serial console device that sets
> the max_in_flight_urbs in the serial device structure.

> +void
> +usb_hcd_poll_urb_irq(struct urb *urb)
> +{
> + struct usb_hcd *hcd;
> +
> + if (!urb)
> + return;

Is this test really needed? The routine is called from only one spot,
after all. It seems more likely that urb will point to deallocated
memory than that it will be NULL. Do you protect against this in
usb_do_console_write?

Maybe you should pass a pointer to a usb_bus structure rather than an
URB. Then none of these issues would arise.

> +
> + hcd = bus_to_hcd(urb->dev->bus);
> + if (hcd)
> + usb_hcd_irq(0, hcd);

This test too looks strange, since it can never fail. (See the
definition of bus_to_hcd to find out why...)

Alan Stern


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/