]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
xhci: zero usb device slot_id member when disabling and freeing a xhci slot
authorMathias Nyman <mathias.nyman@linux.intel.com>
Fri, 16 Mar 2018 14:33:01 +0000 (16:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Mar 2018 14:40:18 +0000 (15:40 +0100)
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 <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mem.c

index 332420d10be91798a3cd73fe44b3d8bc72f01036..e5ace8995b3b39581554e9b6c544f4300d908122 100644 (file)
@@ -913,6 +913,8 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
        if (dev->out_ctx)
                xhci_free_container_ctx(xhci, dev->out_ctx);
 
+       if (dev->udev && dev->udev->slot_id)
+               dev->udev->slot_id = 0;
        kfree(xhci->devs[slot_id]);
        xhci->devs[slot_id] = NULL;
 }