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 --- 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