Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI/VGA: release vga_user_lock before vga_put()
@ 2025-10-01  5:58 Kaushlendra Kumar
  0 siblings, 0 replies; only message in thread
From: Kaushlendra Kumar @ 2025-10-01  5:58 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Kaushlendra Kumar

Release vga_user_lock immediately after list_del() and before calling
vga_put(). The vga_put() function acquires vga_lock internally, and
holding vga_user_lock while calling vga_put(). The VGA resource
operations and loop iteration don't require lock protection, only
the list removal needs lock protection.

This ensures consistent lock ordering and eliminates the deadlock risk
during VGA resource cleanup operations.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 drivers/pci/vgaarb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dba..e86fe7fa3d6f 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -1445,6 +1445,7 @@ static int vga_arb_release(struct inode *inode, struct file *file)
 
 	spin_lock_irqsave(&vga_user_lock, flags);
 	list_del(&priv->list);
+	spin_unlock_irqrestore(&vga_user_lock, flags);
 	for (i = 0; i < MAX_USER_CARDS; i++) {
 		uc = &priv->cards[i];
 		if (uc->pdev == NULL)
@@ -1456,7 +1457,6 @@ static int vga_arb_release(struct inode *inode, struct file *file)
 		while (uc->mem_cnt--)
 			vga_put(uc->pdev, VGA_RSRC_LEGACY_MEM);
 	}
-	spin_unlock_irqrestore(&vga_user_lock, flags);
 
 	kfree(priv);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-01  6:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01  5:58 [PATCH] PCI/VGA: release vga_user_lock before vga_put() Kaushlendra Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox