All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: fix PCI device reference leaks in dispnv04
@ 2026-11-29  6:00 ` Jaeyeong Lee
  0 siblings, 0 replies; 3+ messages in thread
From: Jaeyeong Lee @ 2026-11-29  6:00 UTC (permalink / raw)
  To: Lyude Paul, Danilo Krummrich
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, nouveau, Jaeyeong Lee, stable

pci_get_domain_bus_and_slot() returns a referenced PCI device. The
nForce arbitration and clock paths pass that device directly to
pci_read_config_dword(), losing the pointer and leaking one reference
on every invocation.

Keep the bridge pointer and drop the temporary reference after each
configuration-space read.

Fixes: 2fa6d6cdaf283c05 ("drm/nouveau: deprecate pci_get_bus_and_slot()")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
---
 drivers/gpu/drm/nouveau/dispnv04/arb.c |  6 ++++--
 drivers/gpu/drm/nouveau/dispnv04/hw.c  | 13 +++++++++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index 1d3542d60..15859ec5a 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -209,11 +209,13 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
 	sim_data.two_heads = nv_two_heads(dev);
 	if ((pdev->device & 0xffff) == 0x01a0 /*CHIPSET_NFORCE*/ ||
 	    (pdev->device & 0xffff) == 0x01f0 /*CHIPSET_NFORCE2*/) {
+		struct pci_dev *bridge;
 		uint32_t type;
 		int domain = pci_domain_nr(pdev->bus);
 
-		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1),
-				      0x7c, &type);
+		bridge = pci_get_domain_bus_and_slot(domain, 0, 1);
+		pci_read_config_dword(bridge, 0x7c, &type);
+		pci_dev_put(bridge);
 
 		sim_data.memory_type = (type >> 12) & 1;
 		sim_data.memory_width = 64;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index 8b376f9c8..4b29b77ba 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -223,9 +223,12 @@ nouveau_hw_get_clock(struct drm_device *dev, enum nvbios_pll_type plltype)
 
 	if (plltype == PLL_MEMORY &&
 	    (pdev->device & 0x0ff0) == CHIPSET_NFORCE) {
+		struct pci_dev *bridge;
 		uint32_t mpllP;
-		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 3),
-				      0x6c, &mpllP);
+
+		bridge = pci_get_domain_bus_and_slot(domain, 0, 3);
+		pci_read_config_dword(bridge, 0x6c, &mpllP);
+		pci_dev_put(bridge);
 		mpllP = (mpllP >> 8) & 0xf;
 		if (!mpllP)
 			mpllP = 4;
@@ -234,10 +237,12 @@ nouveau_hw_get_clock(struct drm_device *dev, enum nvbios_pll_type plltype)
 	} else
 	if (plltype == PLL_MEMORY &&
 	    (pdev->device & 0xff0) == CHIPSET_NFORCE2) {
+		struct pci_dev *bridge;
 		uint32_t clock;
 
-		pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 5),
-				      0x4c, &clock);
+		bridge = pci_get_domain_bus_and_slot(domain, 0, 5);
+		pci_read_config_dword(bridge, 0x4c, &clock);
+		pci_dev_put(bridge);
 		return clock / 1000;
 	}
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-29 16:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  6:00 [PATCH] drm/nouveau: fix PCI device reference leaks in dispnv04 Jaeyeong Lee
2026-11-29  6:00 ` Jaeyeong Lee
2026-11-29 16:59 ` sashiko-bot

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.