From nobody Tue Oct 12 19:37:11 2021
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 3AD3517F50CD;
Tue, 12 Oct 2021 19:37:12 +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
client-signature RSA-PSS (4096 bits) client-digest SHA256)
(Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK))
by mx1.freebsd.org (Postfix) with ESMTPS id 4HTQsg4x4rz4gm7;
Tue, 12 Oct 2021 19:37:11 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
(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)
(Client did not present a certificate)
by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 682471A3FC;
Tue, 12 Oct 2021 19:37:11 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CJbBlj059726;
Tue, 12 Oct 2021 19:37:11 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CJbBYp059725;
Tue, 12 Oct 2021 19:37:11 GMT
(envelope-from git)
Date: Tue, 12 Oct 2021 19:37:11 GMT
Message-Id: <202110121937.19CJbBYp059725@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
dev-commits-src-main@FreeBSD.org
From: Ruslan Bukin
Subject: git: aeb76076c698 - main - Prevent repeated deallocation of a resource. Also deactivate resource if needed.
List-Id: Commit messages for all branches of the src repository
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all
List-Help:
List-Post:
List-Subscribe:
List-Unsubscribe:
Sender: owner-dev-commits-src-all@freebsd.org
X-BeenThere: dev-commits-src-all@freebsd.org
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: aeb76076c6985c3accaffa322ce9df47d686e3d1
Auto-Submitted: auto-generated
X-ThisMailContainsUnwantedMimeParts: N
The branch main has been updated by br:
URL: https://cgit.FreeBSD.org/src/commit/?id=aeb76076c6985c3accaffa322ce9df47d686e3d1
commit aeb76076c6985c3accaffa322ce9df47d686e3d1
Author: Ruslan Bukin
AuthorDate: 2021-10-12 19:13:44 +0000
Commit: Ruslan Bukin
CommitDate: 2021-10-12 19:13:44 +0000
Prevent repeated deallocation of a resource.
Also deactivate resource if needed.
Discussed with: jrtc27
Differential Revision: https://reviews.freebsd.org/D32458
---
sys/dev/pci/pci_host_generic.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 03e8baa1b5cf..4d7d9f314dce 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -307,6 +307,7 @@ pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
{
struct generic_pcie_core_softc *sc;
struct rman *rm;
+ int error;
sc = device_get_softc(dev);
@@ -319,7 +320,12 @@ pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
rm = generic_pcie_rman(sc, type, rman_get_flags(res));
if (rm != NULL) {
KASSERT(rman_is_region_manager(res, rm), ("rman mismatch"));
- rman_release_resource(res);
+ if (rman_get_flags(res) & RF_ACTIVE) {
+ error = bus_deactivate_resource(child, type, rid, res);
+ if (error)
+ return (error);
+ }
+ return (rman_release_resource(res));
}
return (bus_generic_release_resource(dev, child, type, rid, res));