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 <jwer...@chromium.org>

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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to