drm/nouveau: fix PCI device reference leaks in dispnv04
Subsystems (4)
PATCH 1/1 drm/nouveau: fix PCI device reference leaks in dispnv04
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.
--- drivers/gpu/drm/nouveau/dispnv04/arb.c | 6 ++++-- drivers/gpu/drm/nouveau/dispnv04/hw.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/arb.c +4 -2
@@ -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 ;
drivers/gpu/drm/nouveau/dispnv04/hw.c +9 -4
@@ -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 ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/nouveau: Fixes trailer cites wrong commit for dispnv04 pci_dev leak --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/nouveau: Fixes trailer cites wrong commit for dispnv04 pci_dev leak
--
commit d77cb05c2913f228ea0d6d6679426ec339d32cca
Author: Jaeyeong Lee <[email protected]>
Quoted 7 lines
drm/nouveau: fix PCI device reference leaks in dispnv04
pci_get_domain_bus_and_slot()returns a referenced PCI device. The nForce arbitration and clock paths pass that device directly topci_read_config_dword(), losing the pointer and leaking one reference on every invocation.
Quoted 6 lines
Keep the bridge pointer and drop the temporary reference after each configuration-space read.
Fixes 2fa6d6cdaf283c05 ("drm/nouveau: deprecate pci_get_bus_and_slot()")Signed-off-by Jaeyeong Lee <[email protected]>
[Severity: Low]
Should the Fixes: tag point to 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs") instead?
Commit 2fa6d6cdaf28 ("drm/nouveau: deprecate pci_get_bus_and_slot()") only replaced pci_get_bus_and_slot() with pci_get_domain_bus_and_slot(), and pci_get_bus_and_slot() already returned a referenced struct pci_dev that required pci_dev_put().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1