usb: xhci: WAR fix panic in xhci_free_dev
joyw [Thu, 31 Jan 2013 10:51:25 +0000 (18:51 +0800)]
Avoid kernel panic in xhci_free_dev function.
Add WRAN_ON to get noticed when issue reproduced.

Change-Id: I493166c0032526bfa190a7dc2abb5156309eedd3
Signed-off-by: joyw <joyw@nvidia.com>
Reviewed-on: http://git-master/r/196187
Reviewed-by: Ajay Gupta <ajayg@nvidia.com>
Tested-by: Ajay Gupta <ajayg@nvidia.com>
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jui Chang Kuo <jckuo@nvidia.com>

drivers/usb/host/xhci.c

index 37e82bf..3206624 100644 (file)
@@ -3365,6 +3365,10 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
 
        virt_dev = xhci->devs[udev->slot_id];
 
+       WARN_ON(!virt_dev);
+       if (!virt_dev)
+               return;
+
        /* Stop any wayward timer functions (which may grab the lock) */
        for (i = 0; i < 31; ++i) {
                virt_dev->eps[i].ep_state &= ~EP_HALT_PENDING;