aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.c
diff options
context:
space:
mode:
authorMatt Evans <matt@ozlabs.org>2011-03-28 22:40:56 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2011-05-02 19:42:50 -0400
commit7ed603ecf8b68ab81f4c83097d3063d43ec73bb8 (patch)
tree3eed33c09dda5e98e79692e69a1270d48a6f8299 /drivers/usb/host/xhci.c
parent92a3da410aac6e14daaefe13c60368ca28e85830 (diff)
xhci: Add an assertion to check for virt_dev=0 bug.
During a "plug-unplug" stress test on an NEC xHCI card, a null pointer dereference was observed. xhci_address_device() dereferenced a null virt_dev (possibly an erroneous udev->slot_id?); this patch adds a WARN_ON & message to aid debug if it can be recreated. Signed-off-by: Matt Evans <matt@ozlabs.org> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r--drivers/usb/host/xhci.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index e8ab1899c88e..5c0ae90df31e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2546,6 +2546,17 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
2546 2546
2547 virt_dev = xhci->devs[udev->slot_id]; 2547 virt_dev = xhci->devs[udev->slot_id];
2548 2548
2549 if (WARN_ON(!virt_dev)) {
2550 /*
2551 * In plug/unplug torture test with an NEC controller,
2552 * a zero-dereference was observed once due to virt_dev = 0.
2553 * Print useful debug rather than crash if it is observed again!
2554 */
2555 xhci_warn(xhci, "Virt dev invalid for slot_id 0x%x!\n",
2556 udev->slot_id);
2557 return -EINVAL;
2558 }
2559
2549 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); 2560 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
2550 /* 2561 /*
2551 * If this is the first Set Address since device plug-in or 2562 * If this is the first Set Address since device plug-in or