Re: [Bugme-new] [Bug 19192] New: Oops after removing unauthorized USB device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 28 Sep 2010, Ming Lei wrote:

> The following patch can fix the oops, if no objections from other
> guys, I will submit a formal version.
> 
> The oops is caused by usb_enable_interface called from
> usb_unbind_interface, usb_enable_interface can make
> udev->ep_out[epnum] point to usb_host_endpoint instance
> which will be freed from usb_destroy_configuration later, so when
> the device is removed from usb bus, oops will happen since
> usb_disable_device is called again from usb_disconnect to touch
> this freed usb_host_endpoint instance.

Your diagnosis looks right, but your solution is wrong.  The problem is 
that the endpoints need to be disabled reliably when a configuration is 
changed, even though unbinding an interface can cause its endpoints to 
be re-enabled.  This really has nothing to do with authorization.

The patch below should work.

Alan Stern


Index: usb-2.6/drivers/usb/core/message.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/message.c
+++ usb-2.6/drivers/usb/core/message.c
@@ -1218,6 +1218,8 @@ void usb_enable_interface(struct usb_dev
 	struct usb_host_interface *alt = intf->cur_altsetting;
 	int i;
 
+	if (intf->unregistering)
+		return;
 	for (i = 0; i < alt->desc.bNumEndpoints; ++i)
 		usb_enable_endpoint(dev, &alt->endpoint[i], reset_eps);
 }
@@ -1274,6 +1276,8 @@ int usb_set_interface(struct usb_device 
 			interface);
 		return -EINVAL;
 	}
+	if (iface->unregistering)
+		return -ESHUTDOWN;
 
 	alt = usb_altnum_to_altsetting(iface, alternate);
 	if (!alt) {

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux