Re: [PATCH] usb:xhci:Fix slot_id resource race conflict
From: Greg KH
Date: Thu Jul 24 2025 - 02:37:04 EST
On Thu, Jul 24, 2025 at 08:40:12PM +0800, Weitao Wang wrote:
> @@ -4085,10 +4086,11 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
> for (i = 0; i < 31; i++)
> virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING;
> virt_dev->udev = NULL;
> - xhci_disable_slot(xhci, udev->slot_id);
> + ret = xhci_disable_slot(xhci, udev->slot_id);
>
> spin_lock_irqsave(&xhci->lock, flags);
> - xhci_free_virt_device(xhci, udev->slot_id);
> + if (ret)
> + xhci_free_virt_device(xhci, udev->slot_id);
> spin_unlock_irqrestore(&xhci->lock, flags);
Shouldn't you lock/unlock only if ret is set?
thanks,
greg k-h