Commit af8eb7df authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] USB: allocate memory for reset earlier

if we fail with -ENOMEM, we should do it before the device must be
reparsed.
parent 7e226ccb
......@@ -1198,12 +1198,18 @@ int usb_physical_reset_device(struct usb_device *dev)
if (port < 0)
return -ENOENT;
descriptor = kmalloc(sizeof *descriptor, GFP_NOIO);
if (!descriptor) {
return -ENOMEM;
}
down(&usb_address0_sem);
/* Send a reset to the device */
if (usb_hub_port_reset(parent, port, dev, HUB_SHORT_RESET_TIME)) {
usb_hub_port_disable(parent, port);
up(&usb_address0_sem);
kfree(descriptor);
return(-ENODEV);
}
......@@ -1213,6 +1219,7 @@ int usb_physical_reset_device(struct usb_device *dev)
err("USB device not accepting new address (error=%d)", ret);
usb_hub_port_disable(parent, port);
up(&usb_address0_sem);
kfree(descriptor);
return ret;
}
......@@ -1230,10 +1237,7 @@ int usb_physical_reset_device(struct usb_device *dev)
* If nothing changed, we reprogram the configuration and then
* the alternate settings.
*/
descriptor = kmalloc(sizeof *descriptor, GFP_NOIO);
if (!descriptor) {
return -ENOMEM;
}
ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor,
sizeof(*descriptor));
if (ret < 0) {
......@@ -1260,7 +1264,7 @@ int usb_physical_reset_device(struct usb_device *dev)
"(expected %Zi, got %i)",
dev->devpath,
sizeof(dev->descriptor), ret);
clear_bit(dev->devnum, dev->bus->devmap.devicemap);
dev->devnum = -1;
return -EIO;
......
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