mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "WeitaoWang-oc@zhaoxin.com" <WeitaoWang-oc@zhaoxin.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <mathias.nyman@intel.com>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <WeitaoWang@zhaoxin.com>,
	<wwt8723@163.com>, <CobeChen@zhaoxin.com>
Subject: Re: [PATCH] usb:xhci:Fix slot_id resource race conflict
Date: Thu, 24 Jul 2025 23:24:10 +0800	[thread overview]
Message-ID: <c52e3bc8-3618-cc99-a936-6576fef3215b@zhaoxin.com> (raw)
In-Reply-To: <2025072425-sixtyfold-curling-88ff@gregkh>

On 2025/7/24 14:36, Greg KH wrote:
> 
> 
> [这封邮件来自外部发件人 谨防风险]
> 
> 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?

Yes,it's my mistake,here's code should like this:

ret = xhci_disable_slot(xhci, udev->slot_id);
if (ret) {
	spin_lock_irqsave(&xhci->lock, flags);
	xhci_free_virt_device(xhci, udev->slot_id);
	spin_unlock_irqrestore(&xhci->lock, flags);
}
Thanks for your suggestion. I'll revise it in the next patch version.

Best Regards,
weitao


> greg k-h
> .

      reply	other threads:[~2025-07-24  7:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24 12:40 Weitao Wang
2025-07-24  6:35 ` Greg KH
2025-07-24 15:30   ` WeitaoWang-oc
2025-07-24  6:36 ` Greg KH
2025-07-24 15:24   ` WeitaoWang-oc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c52e3bc8-3618-cc99-a936-6576fef3215b@zhaoxin.com \
    --to=weitaowang-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=WeitaoWang@zhaoxin.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=wwt8723@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®