Skip to content

Commit fae65ef

Browse files
committed
xen/pciback: don't call pcistub_device_put() under lock
pcistub_device_put() shouldn't be called under spinlock, as it can sleep. For this reason pcistub_device_get_pci_dev() needs to be modified: instead of always calling pcistub_device_get() just do the call of pcistub_device_get() only if it is really needed. This removes the need to call pcistub_device_put(). Reported-by: Dan Carpenter <error27@gmail.com> Link: https://lore.kernel.org/lkml/Y+JUIl64UDmdkboh@kadam/ Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Link: https://lore.kernel.org/r/20230328084549.20695-1-jgross@suse.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 457391b commit fae65ef

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/xen/xen-pciback/pci_stub.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,15 @@ static struct pci_dev *pcistub_device_get_pci_dev(struct xen_pcibk_device *pdev,
194194
struct pci_dev *pci_dev = NULL;
195195
unsigned long flags;
196196

197-
pcistub_device_get(psdev);
198-
199197
spin_lock_irqsave(&psdev->lock, flags);
200198
if (!psdev->pdev) {
201199
psdev->pdev = pdev;
202200
pci_dev = psdev->dev;
203201
}
204202
spin_unlock_irqrestore(&psdev->lock, flags);
205203

206-
if (!pci_dev)
207-
pcistub_device_put(psdev);
204+
if (pci_dev)
205+
pcistub_device_get(psdev);
208206

209207
return pci_dev;
210208
}

0 commit comments

Comments
 (0)