usb: hub: take hub->hdev reference when processing from eventlist
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 10 Sep 2014 19:07:50 +0000 (15:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 5 Oct 2014 21:52:15 +0000 (14:52 -0700)
commit3f6622c77fe9a0bc5ed668e5e9b03944e3cd80a4
tree4b944cdf6b57da6d50e2ccf0ad1dfd33a7546ec3
parentfe4b28ee560fc60ccd1f66ec218ee2aa80ba4612
usb: hub: take hub->hdev reference when processing from eventlist

commit c605f3cdff53a743f6d875b76956b239deca1272 upstream.

During surprise device hotplug removal tests, it was observed that
hub_events may try to call usb_lock_device on a device that has already
been freed. Protect the usb_device by taking out a reference (under the
hub_event_lock) when hub_events pulls it off the list, returning the
reference after hub_events is finished using it.

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Suggested-by: David Bulkow <david.bulkow@stratus.com> for using kref
Suggested-by: Alan Stern <stern@rowland.harvard.edu> for placement
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hub.c