Skip to content

Commit a400efe

Browse files
matnymangregkh
authored andcommitted
xhci: zero usb device slot_id member when disabling and freeing a xhci slot
set udev->slot_id to zero when disabling and freeing the xhci slot. Prevents usb core from calling xhci with a stale slot id. xHC controller may be reset during resume to recover from some error. All slots are unusable as they are disabled and freed. xhci driver starts slot enumeration again from 1 in the order they are enabled. In the worst case a stale udev->slot_id for one device matches a newly enabled slot_id for a different device, causing us to perform a action on the wrong device. Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0c34191 commit a400efe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
913913
if (dev->out_ctx)
914914
xhci_free_container_ctx(xhci, dev->out_ctx);
915915

916+
if (dev->udev && dev->udev->slot_id)
917+
dev->udev->slot_id = 0;
916918
kfree(xhci->devs[slot_id]);
917919
xhci->devs[slot_id] = NULL;
918920
}

0 commit comments

Comments
 (0)