From nobody Wed Nov 18 07:42:08 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTtpm3j1Nz6yxkR for ; Wed, 18 Nov 2026 07:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTtpm1KYXz4KJp for ; Wed, 18 Nov 2026 07:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794987728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B20hSgLuixoFJQonOnMEoFh4u1rP84uNybTcIfp9Vn0=; b=BOMkUDbqLLdy4R99qnLYF+3x+u5YSp0bjqMN9lgtu3yXUX2p32A8E4mOHLp7OFf9R+HFux OsMXIVfMespO3RRElVuVAdu/WnY85eKU1r2VPzCtjRcLO3q38T6HMJ6pkfGLZGHSywtlL6 JlsR4E1ZYo772/N9imz0q79idK0XJ4X8twsRIEjptJNkQHQ+QHEzKqagpYk8+ImEJOP8Ry J8iOux8eNP/kvqdtGiig4zttwt+N+XzyJuHY3rXYmeRx47qsez/zj/zJNDD/IjNYPMeXuv oU3Frs01FQPhVZcwhzM7Gs96uwAGhmKgHACLe0N6iRD9LqVwjJZAsMnXkGjlvQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794987728; b=aNivGOajJp41Uo0ruUSV8dh+ZsY3igloMPwMD83Wrx0G/GIo7pZWZkSqBce5GZXe9gOnSj EYhz7p25nzzmAeeONQi1aCfVuJathLwf5ATTWjjtQPeUwZiHhKBt70qTNTYyPPTp2d7ZEP Hymk8VwuLK3RkeUmODhm9/QwS3V/LznyaIkwxcd5T8TCyBQ8C5KB/uJJe22juAXAqlQcJZ K++kfj6o7G0uGnSMex6biXGCtqUoP6hpiX4AyDGOIGEfFDRtfze9wVxC2QuXf6bm8f/L2t 2o6LZoaxrI4savWufX9WObhIRigdfJocyPHrlrPuDpKK83E3sv4tn7QXDFMWHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794987728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B20hSgLuixoFJQonOnMEoFh4u1rP84uNybTcIfp9Vn0=; b=JP9YaDcsLJdTUf6c+4hF0Jk9agGQt7/bDxu4IT1UpGv8uzb2p7bfanZlX4u9ePCSnWHkPJ puH4POykv8p3qIO1K/dJAwHVvVmTCVU6rHYx8QqUHvmz+pvjGgqntMkUvXWOY220+G6zK9 SI2M+JnXWtrNknpZDqNrnSoD8OAQ1oY/Insms42YKi0+kAvD2XXJs5U013pyO6ihn6ds9J t1WEyOvLgvY6mxQgy4h/kpqqQF+LaJCENg8LxSKZTfaSP54styjnRxjODTDxKcndE9DbZ9 /W6NibXJaGbz4jOL2H/41AiC2ysA1ESqevvUYbEZ58ZUm76CyXRrvEpfkc1MTw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTtpm10b1z1JqT for ; Wed, 18 Nov 2026 07:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 149ab by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 07:42:08 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 812bdff114cf - main - linuxkpi: Release the "from" device in pci_get_class() and pci_get_base_class() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 812bdff114cf2473ab1f45e37d3a1a8742d80c64 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 07:42:08 +0000 Message-Id: <6afd56d0.149ab.3ea7d830@gitrepo.freebsd.org> The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=812bdff114cf2473ab1f45e37d3a1a8742d80c64 commit 812bdff114cf2473ab1f45e37d3a1a8742d80c64 Author: Emmanuel Vadot AuthorDate: 2026-11-04 08:14:38 +0000 Commit: Emmanuel Vadot CommitDate: 2026-11-18 07:42:02 +0000 linuxkpi: Release the "from" device in pci_get_class() and pci_get_base_class() On Linux the pci_get_*() iterators drop the reference of the device passed as "from" once the next one has been looked up, so a loop like while ((pch = pci_get_class(class, pch))) does not leak anything. LinuxKPI allocates a new pci_dev for every device it returns but never released "from", so each device but the last one was leaked together with its kobject, its name and its path name. i915 does exactly this in intel_detect_pch() and leaked a device at every load. Drop the reference, but only for the devices created by lkpinew_pci_dev(); the pci_dev of a device attached to a driver belongs to the bus. Differential Revision: https://reviews.freebsd.org/D61222 --- sys/compat/linuxkpi/common/src/linux_pci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 8270f3bed54a..a3e55c136b4a 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -560,6 +560,19 @@ lkpinew_pci_dev(device_t dev) return (pdev); } +/* + * Linux drops the reference on the "from" device of the pci_get_*() iterators + * once the next device has been looked up. Only do it for the devices which + * were created by lkpinew_pci_dev(); the other ones belong to the bus. + */ +static void +lkpi_pci_put_from(struct pci_dev *from) +{ + + if (from != NULL && from->dev.release == lkpinew_pci_dev_release) + pci_dev_put(from); +} + struct pci_dev * lkpi_pci_get_class(unsigned int class, struct pci_dev *from) { @@ -571,6 +584,7 @@ lkpi_pci_get_class(unsigned int class, struct pci_dev *from) devfrom = from->dev.bsddev; dev = pci_find_class_from(class >> 16, (class >> 8) & 0xFF, devfrom); + lkpi_pci_put_from(from); if (dev == NULL) return (NULL); @@ -589,6 +603,7 @@ lkpi_pci_get_base_class(unsigned int baseclass, struct pci_dev *from) devfrom = from->dev.bsddev; dev = pci_find_base_class_from(baseclass, devfrom); + lkpi_pci_put_from(from); if (dev == NULL) return (NULL);