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)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 9 May 2015 22:16:14 +0000 (23:16 +0100)
commit52c28541efcc9d5bd0a4cb223aade27ed81422bb
tree22732b9cfac4cc2660526ab67b13671734cac8ec
parent16cef17b05cb56f0088595355597be55246c668b
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: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/core/hcd.c