USB: fix use-after-free bug in usb_hcd_unlink_urb()
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 30 Jan 2015 17:58:26 +0000 (12:58 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2015 22:40:51 +0000 (14:40 -0800)
commitc237545ea8eab3d3e7647bde17634f51327847ff
tree1269f1a4d79f4a37d5984ae8d222933f78c48f48
parent931c8f77302707c736236b3d8b4c4ad0854b51c8
USB: fix use-after-free bug in usb_hcd_unlink_urb()

commit c99197902da284b4b723451c1471c45b18537cde upstream.

The usb_hcd_unlink_urb() routine in hcd.c contains two possible
use-after-free errors.  The dev_dbg() statement at the end of the
routine dereferences urb and urb->dev even though both structures may
have been deallocated.

This patch fixes the problem by storing urb->dev in a local variable
(avoiding the dereference of urb) and moving the dev_dbg() up before
the usb_put_dev() call.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Joe Lawrence <joe.lawrence@stratus.com>
Tested-by: Joe Lawrence <joe.lawrence@stratus.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hcd.c