git: aeb76076c698 - main - Prevent repeated deallocation of a resource. Also deactivate resource if needed.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 Oct 2021 19:37:11 UTC
The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=aeb76076c6985c3accaffa322ce9df47d686e3d1 commit aeb76076c6985c3accaffa322ce9df47d686e3d1 Author: Ruslan Bukin <br@FreeBSD.org> AuthorDate: 2021-10-12 19:13:44 +0000 Commit: Ruslan Bukin <br@FreeBSD.org> 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));