linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Long Li <longli@microsoft.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: RE: [bug report] PCI: hv: Fix a race condition when removing the device
Date: Tue, 24 Aug 2021 07:23:24 +0000	[thread overview]
Message-ID: <BY5PR21MB1506E144FA993DB38458599CCEC59@BY5PR21MB1506.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20210823152130.GA21501@kili>

> Subject: [bug report] PCI: hv: Fix a race condition when removing the device
> 
> Hello Long Li,
> 
> The patch 94d22763207a: "PCI: hv: Fix a race condition when removing the
> device" from May 12, 2021, leads to the following Smatch static checker
> warning:
> 
> 	drivers/pci/controller/pci-hyperv.c:3294 hv_pci_bus_exit()
> 	warn: sleeping in atomic context
> 
> drivers/pci/controller/pci-hyperv.c
>     3287
>     3288 	if (!keep_devs) {
>     3289 		/* Delete any children which might still exist. */
>     3290 		spin_lock_irqsave(&hbus->device_list_lock, flags);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This takes a spinlock.
> 
>     3291 		list_for_each_entry_safe(hpdev, tmp, &hbus->children,
> list_entry) {
>     3292 			list_del(&hpdev->list_entry);
>     3293 			if (hpdev->pci_slot)
> --> 3294 				pci_destroy_slot(hpdev->pci_slot);
>                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The
> pci_destroy_slot() function takes a mutex and you can't take a mutex when
> you're holding a spinlock because it can sleep.
> 
>     3295 			/* For the two refs got in new_pcichild_device() */
>     3296 			put_pcichild(hpdev);
>     3297 			put_pcichild(hpdev);
>     3298 		}
>     3299 		spin_unlock_irqrestore(&hbus->device_list_lock, flags);
>     3300 	}
>     3301
>     3302 	ret = hv_send_resources_released(hdev);
>     3303 	if (ret) {
>     3304 		dev_err(&hdev->device,
> 
> regards,
> dan carpenter

Thank you, Dan. I have submitted a patch to fix this.

Long

      reply	other threads:[~2021-08-24  7:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 15:21 [bug report] PCI: hv: Fix a race condition when removing the device Dan Carpenter
2021-08-24  7:23 ` Long Li [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=BY5PR21MB1506E144FA993DB38458599CCEC59@BY5PR21MB1506.namprd21.prod.outlook.com \
    --to=longli@microsoft.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-hyperv@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).