Skip to content

Commit 44a182b

Browse files
matnymangregkh
authored andcommitted
xhci: Fix use-after-free in xhci_free_virt_device
KASAN found a use-after-free in xhci_free_virt_device+0x33b/0x38e where xhci_free_virt_device() sets slot id to 0 if udev exists: if (dev->udev && dev->udev->slot_id) dev->udev->slot_id = 0; dev->udev will be true even if udev is freed because dev->udev is not set to NULL. set dev->udev pointer to NULL in xhci_free_dev() The original patch went to stable so this fix needs to be applied there as well. Fixes: a400efe ("xhci: zero usb device slot_id member when disabling and freeing a xhci slot") Cc: <[email protected]> Reported-by: Guenter Roeck <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Tested-by: Guenter Roeck <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9aea9b6 commit 44a182b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/usb/host/xhci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,6 +3621,7 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
36213621
del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
36223622
}
36233623
xhci_debugfs_remove_slot(xhci, udev->slot_id);
3624+
virt_dev->udev = NULL;
36243625
ret = xhci_disable_slot(xhci, udev->slot_id);
36253626
if (ret)
36263627
xhci_free_virt_device(xhci, udev->slot_id);

0 commit comments

Comments
 (0)