Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86AFF606A31C for ; Sun, 29 Nov 2026 16:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=LotKnx/u Received: from kara.freedesktop.org (unknown [131.252.210.166]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E56E10EC40; Sun, 29 Nov 2026 16:48:49 +0000 (UTC) Received: from kara.freedesktop.org (localhost [127.0.0.1]) by kara.freedesktop.org (Postfix) with ESMTP id 399CA4046A; Sun, 29 Nov 2026 16:48:49 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.freedesktop.org; s=20240201; t=1795970929; b=gKcmAVK6XT6PcT+V3b11wyI4Id2Rotx80dTHVADqfqrQppUN+1YyLoPqdCYUp0T6Nfz/H UpE4KhOmhW7WbEzTEV2Av/Wmk9fv+Nzow5QMxnNUkDWntRfoGN0nmrzYdfEFVr8FQ0WC93N Z25hyaWSjXoTx/zEheDSXrve/alXaoD/KcH5G74Baj+4qEHFa88PbqjwAKWNUMvzLyu+t3X s6zoK2NNVvUfqlHy2YAh4dj+T8tSOq2N18+zUcFZZFpIcDXQA/lXiiKECx4cKqFaXUCFZvQ yZGn7y3VusCGeJz/4+YbNGShyTLSw4OLvg9V/vT92fZULQnOFFWt+/6h6UCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.freedesktop.org; s=20240201; t=1795970929; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=yheUDP7W22PeKOyEYqLTcUmV5fXp8bObQqhGexSofSA=; b=pIGJu/cgBFpmfBZOmZ9UwtrRzTfMXwPtImJPDwF7G/YN1SwQISixdY+qviYgaPeTxOPNS gd3k/nbWoarsL/yPnK561CUnAJGRZ5aEpE6oDZQ5VAzO3eDQd2qbBNJeiWDxWtOReaTddDy MKBR+X3VdtYXvOmsupZhx7F7Na6LadUPendWYi56QntJTvUguNxeJPG27pYYv463yyz6Fpd 5bdS+fsGkImHtlnEIl+2kMnPGwHIVZN/K2deXaeLSuvtivl2b+GlaHyWjH9EE+d17jE3rzh dc+b5x6RzRVM2pWD5PZ5Kj4y8K7NdixysYT7uYX6cPemXsDAuSyKIxlai3tQ== ARC-Authentication-Results: i=1; mail.freedesktop.org; dkim=pass header.d=gmail.com; arc=none; dmarc=pass header.from=gmail.com policy.dmarc=quarantine Authentication-Results: mail.freedesktop.org; dkim=pass header.d=gmail.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=gmail.com policy.dmarc=quarantine Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by kara.freedesktop.org (Postfix) with ESMTPS id 03BCD4015C for ; Sun, 29 Nov 2026 05:01:07 +0000 (UTC) Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id E872210E178 for ; Sun, 29 Nov 2026 05:01:01 +0000 (UTC) Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-862b98b2e47so3652260a34.2 for ; Sat, 28 Nov 2026 21:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795928461; x=1796533261; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=yheUDP7W22PeKOyEYqLTcUmV5fXp8bObQqhGexSofSA=; b=LotKnx/usfX+qcQwiulDjUI0a7gdQzgtm+iaiiy4loxHmj3Z3hOGFwqP/zp12mDrYC QyPDGiEf0kek1SrK8TZpL1tAw9Td+FGxDFBEfq/idr+mIZpuVA4K69j8toleV/PcacIF fWFu/fXUi9eHH8Lp6pvvJP1H8F/D4LjZfVFQc1E8uH+sagwEj0EsnpqjL8NM54LTNRL0 6yqWIHKZd+FIP+cYaQA+8tP3ZL2O8tFQinCLFW0n9EzpGVdRwPYO0JfaoKiTlwSJUsjC Z2OSJpCiKxZXdur9CNSvsMx5ZjnQ14PtL2B8DD0uu3tlT0LqMnVpIIkWEdBqxKr6Z8lt bVGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795928461; x=1796533261; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yheUDP7W22PeKOyEYqLTcUmV5fXp8bObQqhGexSofSA=; b=VIybwsLpt+spV+qBTrSvADdHp87qH87AyQ2HGhrQP9B2O9nBI3+KFIpznp+8mxhHJV Ereq/trrvyKFEmhQD/kRO2qyqhiu0zmdhm7E+15ljRdC4qkdjcVv9IUJ752yUVoYkwX+ PJBtms6/QSeVb5crV0TVs7HbI4tQi9NM97GX2YqA1q+NKYoTtZaczIDWP2Zm/FHej8rU zl5EXABQHX/w6QRlnaJHq0QvRN5o9ONGCBla4mTkfEVxDjJt6MysXBc2BBTmiuZvI79J K4Cv0X3axeK1TiAO/gHNiDL3JrhulGA9VVLZr/lkADZQFOvPhCsHeUGP9AQ7WYVWk233 ttrA== X-Forwarded-Encrypted: i=1; AL+hErHVtVcQQp0YfVxpRSYs/miUkOkBU2tS5ix1/1NVLR92wOzMYgSL+O3pGkg3vbD7ZFw9wRUhU6K8@lists.freedesktop.org X-Gm-Message-State: APuU4Z/T1rZUGPID9eLYrzqEAUKJfaXlGf3mZgHXeR+r/jHCjbcADbTK 5+pI7YqK8kHhUcbT3dN7N8dmLvZyDrZ9zxrKZ/i2xv48tiEAQoQupZAa X-Gm-Gg: AZFdTZc1TYUdDR7pq5pxnFEt4fICI+uGF084DP1ZQZMHXec3se8NcHc3KtCH8BNTKKD EUWe1mkeeGwWsbJv7ye7Gnt6kqh7uZC5vgP9+nVYDmKX1PMFU9UYTfKLQIXoa51bKq0qhy3LWT7 X4fyMFH6wbLGi60iLBEuCdzQCmHbK2psvIYJw4Bat+plbiKbXRdqV0u3aFT34S8vt2FdtXFZheH YI5c+3BfxPwLOcWwlWyu939JgTCBiVrCZaYC28hfDpkQz2yGdAwDmVvqAsNeJuM2b19KTUtm6jw lNoM1YwGBKqe80sHHODqsczkDvQm+RkHGRonhckX0uEmnmHZu3jsCkoYwEHFSK4ParaW8M5V4Sv 3TorzjKgPWTCVCyAnQW4hU4o8iNWLI/oVpAfskW5L+3Qk/NDey3v+kj8dFUFJNyA60iEDCHOXI4 YbF5DvFUtU2j6tfpZVWyYrGRllBd2+Tl3LeEAMqK96ccFQIQnDs6dtjnhytEp4jzjY+4JzdxkYP esjd4pbSINkC8z9re8YklqUGROes8r6rfPM2EXyEeuQSL6Yhsq3GwYtqq3JI2qhhB1V7T5iiQ6q jqHb1ATSfzYsI7jpqa2FR0Q7HvFhy0KoO/N+gu99XDMfmevofyU8ydZMx1qNcJxwsMyR/oyQ2Rl 48h5UyvbYZadotEhQ5lh9sCez9cjXSjI8x+vJnufXdDTh6hk0Oztg4R+R2eCH+DQ1r4A= X-Received: by 2002:a05:6830:600d:b0:863:a948:280f with SMTP id 46e09a7af769-863a9482b4emr3000656a34.30.1795928460839; Sat, 28 Nov 2026 21:01:00 -0800 (PST) Received: from tempest-testimage-cc-centos9-stream-server-1191361818 (chi-dyn-129-114-108-164.tacc.chameleoncloud.org. [129.114.108.164]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863168f6d33sm20192329a34.18.2026.11.28.21.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 21:00:59 -0800 (PST) From: Yuho Choi To: Lyude Paul , Danilo Krummrich Subject: [PATCH] drm/nouveau/dispnv04: Fix PCI device reference leaks on nForce Date: Sun, 29 Nov 2026 05:00:51 +0000 Message-ID: <20261129050056.953620-2-oss.patchbox@gmail.com> X-Mailer: git-send-email 2.56.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: oss.patchbox@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: UXCH3LI5DRYJGADEO7NUXOCT3LTP4H4E X-Message-ID-Hash: UXCH3LI5DRYJGADEO7NUXOCT3LTP4H4E X-Mailman-Approved-At: Sun, 29 Nov 2026 16:48:47 +0000 CC: Maarten Lankhorst , Maxime Ripard , Simona Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Yuho Choi X-Mailman-Version: 3.3.10 Precedence: list List-Id: Nouveau development list Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- 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