Re: [PATCH v2] usb: core: Make sure usb_set_configuration(-1) cannot fail

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

 



On Thu, 5 Dec 2013, Julius Werner wrote:

> usb_deauthorize_device() tries to unset the configuration of a USB
> device and then unconditionally blows away the configuration descriptors
> with usb_destroy_configuration(). This is bad if the
> usb_set_configuration() call failed before the configuration could be
> correctly unset, since pointers like udev->actconfig can keep pointing
> to the now invalid memory. We have encountered hard to reproduce crashes
> from devices disconnected during suspend due to this, where khubd's
> disconnect handling races with userspace tools that change authorization
> on resume.
> 
> It seems desirable that a USB device can always be marked as
> unconfigured (reclaiming its bandwidth) in the kernel, regardless of
> communication problems. This patch changes usb_set_configuration() to
> ignore all failures in the case where no new configuration is being set.
> 
> Signed-off-by: Julius Werner <jwerner@xxxxxxxxxxxx>

Sorry for not getting back to this sooner.  Ironically, it looks like 
this change isn't needed any more, thanks to Thomas Pugliese's patch:

	http://marc.info/?l=linux-usb&m=138661805209999&w=2

> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c

> @@ -1774,7 +1775,7 @@ free_interfaces:
>  
>  	/* Wake up the device so we can send it the Set-Config request */
>  	ret = usb_autoresume_device(dev);
> -	if (ret)
> +	if (ret && cp)
>  		goto free_interfaces;

That isn't quite right.  If the autoresume fails then we have to skip 
the autosuspend call later on.

Alan Stern

--
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