From: Yuho Choi <oss.patchbox@gmail.com>
To: Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] drm/nouveau/dispnv04: Fix PCI device reference leaks on nForce
Date: Sun, 29 Nov 2026 05:00:51 +0000 [thread overview]
Message-ID: <20261129050056.953620-2-oss.patchbox@gmail.com> (raw)
nv04_update_arb() and nouveau_hw_get_clock() read memory settings from
functions of the nForce/nForce2 host bridge. They look the device up
with pci_get_domain_bus_and_slot(), which returns it with an elevated
reference count, and pass it straight to pci_read_config_dword()
without ever dropping that reference.
Both are called from nv04_crtc_do_mode_set_base() through
nouveau_calc_arb(), so every mode set on an nForce or nForce2 IGP
leaks two references to host bridge functions.
Keep the device in a local variable and call pci_dev_put() once its
config space has been read, as nv1a_ram_new() does for the same host
bridge.
Fixes: 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64, DRM_NOUVEAU=m, W=1, on drm-misc-fixes). I
don't have an nForce or nForce2 board, and QEMU does not emulate these
GPUs, so I could not run this path.
The lookups could in theory return NULL; that is unchanged here, since
these host bridge functions are always present on nForce chipsets.
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 1d3542d6006b..15859ec5a532 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 8b376f9c8746..4b29b77baaac 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;
}
base-commit: e950f467b8adbfb2f460d9b9454280cdbf597885
--
2.56.1
WARNING: multiple messages have this Message-ID (diff)
From: Yuho Choi <oss.patchbox@gmail.com>
To: Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] drm/nouveau/dispnv04: Fix PCI device reference leaks on nForce
Date: Sun, 29 Nov 2026 05:00:51 +0000 [thread overview]
Message-ID: <20261129050056.953620-2-oss.patchbox@gmail.com> (raw)
nv04_update_arb() and nouveau_hw_get_clock() read memory settings from
functions of the nForce/nForce2 host bridge. They look the device up
with pci_get_domain_bus_and_slot(), which returns it with an elevated
reference count, and pass it straight to pci_read_config_dword()
without ever dropping that reference.
Both are called from nv04_crtc_do_mode_set_base() through
nouveau_calc_arb(), so every mode set on an nForce or nForce2 IGP
leaks two references to host bridge functions.
Keep the device in a local variable and call pci_dev_put() once its
config space has been read, as nv1a_ram_new() does for the same host
bridge.
Fixes: 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64, DRM_NOUVEAU=m, W=1, on drm-misc-fixes). I
don't have an nForce or nForce2 board, and QEMU does not emulate these
GPUs, so I could not run this path.
The lookups could in theory return NULL; that is unchanged here, since
these host bridge functions are always present on nForce chipsets.
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 1d3542d6006b..15859ec5a532 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 8b376f9c8746..4b29b77baaac 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;
}
base-commit: e950f467b8adbfb2f460d9b9454280cdbf597885
--
2.56.1
next reply other threads:[~2026-11-29 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 5:00 Yuho Choi [this message]
2026-11-29 5:00 ` [PATCH] drm/nouveau/dispnv04: Fix PCI device reference leaks on nForce Yuho Choi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129050056.953620-2-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.