All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: longli@microsoft.com
Cc: linux-hyperv@vger.kernel.org
Subject: [bug report] PCI: hv: Fix a race condition when removing the device
Date: Mon, 23 Aug 2021 18:21:30 +0300	[thread overview]
Message-ID: <20210823152130.GA21501@kili> (raw)

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

             reply	other threads:[~2021-08-23 15:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 15:21 Dan Carpenter [this message]
2021-08-24  7:23 ` [bug report] PCI: hv: Fix a race condition when removing the device Long Li

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=20210823152130.GA21501@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=longli@microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.