OSDN Git Service

usb: xhci: fix possible wild pointer
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 3 Jan 2017 16:28:46 +0000 (18:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2017 10:22:44 +0000 (11:22 +0100)
commite224b8b7215fbaf0b7ce70dded685f635412369a
treeecffffe6b37ddec3335f580269337b197ebcad91
parent438efb640e838faf3d40d4ac394fa85834c4b9c5
usb: xhci: fix possible wild pointer

commit 2b985467371a58ae44d76c7ba12b0951fee6ed98 upstream.

handle_cmd_completion() frees a command structure which might be still
referenced by xhci->current_cmd.
This might cause problem when xhci->current_cmd is accessed after that.

A real-life case could be like this. The host takes a very long time to
respond to a command, and the command timer is fired at the same time
when the command completion event arrives. The command completion
handler frees xhci->current_cmd before the timer function can grab
xhci->lock. Afterward, timer function grabs the lock and go ahead with
checking and setting members of xhci->current_cmd.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c