Commit 169567a6 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Fix disconnect bug in dummy_hcd

Greg:

This patch fixes a bug in disconnect handling for the dummy_hcd driver.
After a disconnect the driver would still accept URBs for endpoint 0,
leading to an oops.  It also improves the ad-hoc technique used by the
driver to track its gadget's struct usb_device and fixes the way
port-power changes are handled.  Please apply.

Alan Stern
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent c241d930
......@@ -825,7 +825,6 @@ static int dummy_urb_enqueue (
dum = container_of (hcd, struct dummy, hcd);
spin_lock_irqsave (&dum->lock, flags);
if (!dum->hdev)
dum->hdev = urb->dev->hcpriv;
urb->hcpriv = dum;
if (usb_pipetype (urb->pipe) == PIPE_CONTROL)
......@@ -994,10 +993,17 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep)
return limit;
}
#define is_active(dum) ((dum->port_status & \
(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE | \
USB_PORT_STAT_SUSPEND)) \
== (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE))
static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address)
{
int i;
if (!is_active (dum))
return NULL;
if ((address & ~USB_DIR_IN) == 0)
return &dum->ep [0];
for (i = 1; i < DUMMY_ENDPOINTS; i++) {
......@@ -1011,6 +1017,8 @@ static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address)
return NULL;
}
#undef is_active
#define Dev_Request (USB_TYPE_STANDARD | USB_RECIP_DEVICE)
#define Dev_InRequest (Dev_Request | USB_DIR_IN)
#define Intf_Request (USB_TYPE_STANDARD | USB_RECIP_INTERFACE)
......@@ -1404,9 +1412,8 @@ static int dummy_hub_control (
break;
case USB_PORT_FEAT_POWER:
dum->port_status = 0;
dum->address = 0;
dum->hdev = 0;
dum->resuming = 0;
stop_activity(dum, dum->driver);
break;
default:
dum->port_status &= ~(1 << wValue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment