From nobody Tue Nov 05 01:33:43 2024 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 4Xj9pc0VZPz5cq3D; Tue, 05 Nov 2024 01:33:44 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xj9pb6DWQz4tN0; Tue, 5 Nov 2024 01:33:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730770423; 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=KYTqBjEio8cnucYU4fGPn5XVZx1rHon4UOzkAH6bB+s=; b=Mh9LQ7ZZpiiHgkjvNDkyyzRrSTrDZqBYND0X8ITx7tNfasbBreOenNi73VK9cEBAOeKX7N d/v3BTdFpPvZL47IBEoz8WpgRUiL0qxJWpkUdZWmzEA+tVNzls1NCAIa0MOtZapTjvT0E1 foGhnH+IELzrOAwoai9+/v4PiLoGXWqohfa1azF/6Un1V4Ml0b9HVCI4F3MNfIkc7f7sqa sUIpznMkt2FfFEIeYONQp/ey0B5m3iejIjxYbTf3UHig9hvIdLjqn0Y5imynmDlBsLUk8M BGySvzAt3F1+yCH/62j51eWZ1yrjEVlb60EhOiuxm5wabO35dOvAGf71Ue1YeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730770423; 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=KYTqBjEio8cnucYU4fGPn5XVZx1rHon4UOzkAH6bB+s=; b=qEsAP6wmab6b8e7Cf/HWBvR+/pdEvALiUOaHKlTjTkxTwoxE6tWoY/gIRD0TgAirtmE2sr 6hPldrT25jqRXWiqD9/Ked1kt8O6PfWJb8AOHAj2kdV9nkxiBq/bhTjvpeedbZj68t1ktM 0s0wlwp6PSr8Vou2QmxywBOPJSZtPnetZlL3gIUnENYRmlZf6QKKOODhsbLw1nnnmblBS3 uD/U/0EU/6Ek/VgJI5bzt+29pSSJlbC6dZSPRK2AXyo//yCiPzYyZBTc+mLZXmaJx0H1xz 9QN5+gEn+d4EvP6Trx9YWo7/y5BnERTa/LtU+FAd4HYLVDaXb6SmvEhl7FFtkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730770423; a=rsa-sha256; cv=none; b=ei1nruNC7njorlqaF+dshiLorL9qR/VzkN0lHql52cMXR56qHU3LhsChvXe0BlYU6/SM2p Rgy/uC88qJcllnACTPxFMAq28xovoDRKpz/EC1YXnZo7VWEoVD0pnOjvea9h3lwSufZz1O mZjC2dCdorisxndpoJ2umxE0KOnxyX9ZZJlV/uIeJ2G2wKu2Bo5ZErT9KrPphOYHqryfeD Ce4Qy+JrtgyOWFVY66Ss+Db6WkBahALcvtz2GD1BB7qNyIPSfcoD+veNU3GnMu9vbtEraY bC3Fl8N4ucjKbc/koGUlI9oI/pOar+8/acwleDtKf7Y8r2VsrBv7LNlF5ZB+2A== 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 4Xj9pb5qXfzxZw; Tue, 5 Nov 2024 01:33:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A51XhK3049127; Tue, 5 Nov 2024 01:33:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A51XhaP049124; Tue, 5 Nov 2024 01:33:43 GMT (envelope-from git) Date: Tue, 5 Nov 2024 01:33:43 GMT Message-Id: <202411050133.4A51XhaP049124@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d412c07617eb - main - Check for errors when detaching children first, not last 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d412c07617eb35435668b024bc2cecda05f57f1f Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d412c07617eb35435668b024bc2cecda05f57f1f commit d412c07617eb35435668b024bc2cecda05f57f1f Author: John Baldwin AuthorDate: 2024-11-05 01:30:33 +0000 Commit: John Baldwin CommitDate: 2024-11-05 01:30:33 +0000 Check for errors when detaching children first, not last These detach routines in these drivers all ended with 'return (bus_generic_detach())' meaning that if any child device failed to detach, the parent driver was left in a mostly destroyed state, but still marked attached. Instead, bus drivers should detach child drivers first and return errors before destroying driver state in the parent. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47387 --- sys/arm/nvidia/as3722.c | 7 ++++++- sys/arm/nvidia/drm2/tegra_dc.c | 7 ++++++- sys/arm/nvidia/drm2/tegra_hdmi.c | 8 +++++++- sys/arm/nvidia/drm2/tegra_host1x.c | 7 ++++++- sys/arm/nvidia/tegra_abpmisc.c | 7 ++++++- sys/arm/nvidia/tegra_efuse.c | 7 ++++++- sys/arm/nvidia/tegra_i2c.c | 7 ++++++- sys/arm/nvidia/tegra_mc.c | 7 ++++++- sys/arm/nvidia/tegra_rtc.c | 7 ++++++- sys/arm/ti/ti_adc.c | 7 ++++++- sys/arm64/nvidia/tegra210/max77620.c | 7 ++++++- sys/arm64/nvidia/tegra210/max77620_rtc.c | 7 ++++++- sys/dev/dwwdt/dwwdt.c | 7 ++++++- sys/dev/ena/ena.c | 6 +++++- sys/dev/fdt/simplebus.c | 7 ++++++- sys/dev/gve/gve_main.c | 7 ++++++- sys/dev/iicbus/pmic/act8846.c | 7 ++++++- sys/dev/mana/gdma_main.c | 7 ++++++- sys/powerpc/mpc85xx/pci_mpc85xx.c | 7 ++++++- sys/powerpc/powermac/cuda.c | 7 ++++++- sys/powerpc/powermac/pmu.c | 7 ++++++- 21 files changed, 126 insertions(+), 21 deletions(-) diff --git a/sys/arm/nvidia/as3722.c b/sys/arm/nvidia/as3722.c index ca5f7372aed1..ed5f47363b01 100644 --- a/sys/arm/nvidia/as3722.c +++ b/sys/arm/nvidia/as3722.c @@ -343,6 +343,11 @@ static int as3722_detach(device_t dev) { struct as3722_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->irq_h != NULL) @@ -351,7 +356,7 @@ as3722_detach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static phandle_t diff --git a/sys/arm/nvidia/drm2/tegra_dc.c b/sys/arm/nvidia/drm2/tegra_dc.c index f4168f161f5e..a8a0e3f4abf8 100644 --- a/sys/arm/nvidia/drm2/tegra_dc.c +++ b/sys/arm/nvidia/drm2/tegra_dc.c @@ -1393,6 +1393,11 @@ static int dc_detach(device_t dev) { struct dc_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -1412,7 +1417,7 @@ dc_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_dc_methods[] = { diff --git a/sys/arm/nvidia/drm2/tegra_hdmi.c b/sys/arm/nvidia/drm2/tegra_hdmi.c index e5ce30ac2eb3..067df21c889c 100644 --- a/sys/arm/nvidia/drm2/tegra_hdmi.c +++ b/sys/arm/nvidia/drm2/tegra_hdmi.c @@ -1272,6 +1272,12 @@ static int hdmi_detach(device_t dev) { struct hdmi_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); + sc = device_get_softc(dev); TEGRA_DRM_DEREGISTER_CLIENT(device_get_parent(sc->dev), sc->dev); @@ -1294,7 +1300,7 @@ hdmi_detach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_hdmi_methods[] = { diff --git a/sys/arm/nvidia/drm2/tegra_host1x.c b/sys/arm/nvidia/drm2/tegra_host1x.c index e04a50e4c003..ee43efba5ba7 100644 --- a/sys/arm/nvidia/drm2/tegra_host1x.c +++ b/sys/arm/nvidia/drm2/tegra_host1x.c @@ -586,6 +586,11 @@ static int host1x_detach(device_t dev) { struct host1x_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -608,7 +613,7 @@ host1x_detach(device_t dev) if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static device_method_t host1x_methods[] = { diff --git a/sys/arm/nvidia/tegra_abpmisc.c b/sys/arm/nvidia/tegra_abpmisc.c index 88f9ecde3f31..1f54a918f63b 100644 --- a/sys/arm/nvidia/tegra_abpmisc.c +++ b/sys/arm/nvidia/tegra_abpmisc.c @@ -166,13 +166,18 @@ static int tegra_abpmisc_detach(device_t dev) { struct tegra_abpmisc_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->abp_misc_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->abp_misc_res); if (sc->strap_opt_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 1, sc->strap_opt_res); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_abpmisc_methods[] = { diff --git a/sys/arm/nvidia/tegra_efuse.c b/sys/arm/nvidia/tegra_efuse.c index 35d9380a18a5..dc637e6d0bec 100644 --- a/sys/arm/nvidia/tegra_efuse.c +++ b/sys/arm/nvidia/tegra_efuse.c @@ -499,6 +499,11 @@ static int tegra_efuse_detach(device_t dev) { struct tegra_efuse_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); dev_sc = NULL; @@ -509,7 +514,7 @@ tegra_efuse_detach(device_t dev) if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_efuse_methods[] = { diff --git a/sys/arm/nvidia/tegra_i2c.c b/sys/arm/nvidia/tegra_i2c.c index 0fe1aa7ba48e..b01f1a1fdce4 100644 --- a/sys/arm/nvidia/tegra_i2c.c +++ b/sys/arm/nvidia/tegra_i2c.c @@ -740,6 +740,11 @@ static int tegra_i2c_detach(device_t dev) { struct tegra_i2c_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); tegra_i2c_hw_init(sc); @@ -753,7 +758,7 @@ tegra_i2c_detach(device_t dev) LOCK_DESTROY(sc); if (sc->iicbus) device_delete_child(dev, sc->iicbus); - return (bus_generic_detach(dev)); + return (0); } static phandle_t diff --git a/sys/arm/nvidia/tegra_mc.c b/sys/arm/nvidia/tegra_mc.c index 020c9617b453..0f05c32117e9 100644 --- a/sys/arm/nvidia/tegra_mc.c +++ b/sys/arm/nvidia/tegra_mc.c @@ -280,6 +280,11 @@ static int tegra_mc_detach(device_t dev) { struct tegra_mc_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->irq_h != NULL) @@ -290,7 +295,7 @@ tegra_mc_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_mc_methods[] = { diff --git a/sys/arm/nvidia/tegra_rtc.c b/sys/arm/nvidia/tegra_rtc.c index 07bf51628665..09bd42bc64e3 100644 --- a/sys/arm/nvidia/tegra_rtc.c +++ b/sys/arm/nvidia/tegra_rtc.c @@ -266,6 +266,11 @@ static int tegra_rtc_detach(device_t dev) { struct tegra_rtc_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->irq_h != NULL) @@ -276,7 +281,7 @@ tegra_rtc_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static device_method_t tegra_rtc_methods[] = { diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c index 5a3a337afff5..d13dd87001de 100644 --- a/sys/arm/ti/ti_adc.c +++ b/sys/arm/ti/ti_adc.c @@ -915,6 +915,11 @@ static int ti_adc_detach(device_t dev) { struct ti_adc_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -938,7 +943,7 @@ ti_adc_detach(device_t dev) if (sc->sc_mem_res) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); - return (bus_generic_detach(dev)); + return (0); } static device_method_t ti_adc_methods[] = { diff --git a/sys/arm64/nvidia/tegra210/max77620.c b/sys/arm64/nvidia/tegra210/max77620.c index b33d73e71f90..a7d938cb8123 100644 --- a/sys/arm64/nvidia/tegra210/max77620.c +++ b/sys/arm64/nvidia/tegra210/max77620.c @@ -450,6 +450,11 @@ static int max77620_detach(device_t dev) { struct max77620_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->irq_h != NULL) @@ -458,7 +463,7 @@ max77620_detach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static phandle_t diff --git a/sys/arm64/nvidia/tegra210/max77620_rtc.c b/sys/arm64/nvidia/tegra210/max77620_rtc.c index 29808af27819..dca90549443c 100644 --- a/sys/arm64/nvidia/tegra210/max77620_rtc.c +++ b/sys/arm64/nvidia/tegra210/max77620_rtc.c @@ -366,11 +366,16 @@ static int max77620_rtc_detach(device_t dev) { struct max77620_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } /* diff --git a/sys/dev/dwwdt/dwwdt.c b/sys/dev/dwwdt/dwwdt.c index 89f94fff9bad..c433317a8d87 100644 --- a/sys/dev/dwwdt/dwwdt.c +++ b/sys/dev/dwwdt/dwwdt.c @@ -309,6 +309,7 @@ static int dwwdt_detach(device_t dev) { struct dwwdt_softc *sc = device_get_softc(dev); + int error; if (dwwdt_started(sc)) { /* @@ -318,6 +319,10 @@ dwwdt_detach(device_t dev) return (EBUSY); } + error = bus_generic_detach(dev); + if (error != 0) + return (error); + EVENTHANDLER_DEREGISTER(watchdog_list, sc->sc_evtag); sc->sc_evtag = NULL; @@ -337,7 +342,7 @@ dwwdt_detach(device_t dev) sc->sc_mem_res); } - return (bus_generic_detach(dev)); + return (0); } static int diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index e9d4530e9085..f0b6cec1bb61 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -4030,6 +4030,10 @@ ena_detach(device_t pdev) return (EBUSY); } + rc = bus_generic_detach(pdev); + if (rc != 0) + return (rc); + ether_ifdetach(adapter->ifp); ifmedia_removeall(&adapter->media); @@ -4096,7 +4100,7 @@ ena_detach(device_t pdev) free(ena_dev, M_DEVBUF); - return (bus_generic_detach(pdev)); + return (0); } /****************************************************************************** diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 37db238f2108..0f41d3433d75 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -189,12 +189,17 @@ int simplebus_detach(device_t dev) { struct simplebus_softc *sc; + int rv; + + rv = bus_generic_detach(dev); + if (rv != 0) + return (rv); sc = device_get_softc(dev); if (sc->ranges != NULL) free(sc->ranges, M_DEVBUF); - return (bus_generic_detach(dev)); + return (0); } void diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c index f8a37b9f37a9..15d57ed0f2ac 100644 --- a/sys/dev/gve/gve_main.c +++ b/sys/dev/gve/gve_main.c @@ -820,6 +820,11 @@ gve_detach(device_t dev) { struct gve_priv *priv = device_get_softc(dev); if_t ifp = priv->ifp; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); ether_ifdetach(ifp); @@ -836,7 +841,7 @@ gve_detach(device_t dev) taskqueue_free(priv->service_tq); if_free(ifp); - return (bus_generic_detach(dev)); + return (0); } static device_method_t gve_methods[] = { diff --git a/sys/dev/iicbus/pmic/act8846.c b/sys/dev/iicbus/pmic/act8846.c index 5e166247f79b..e55fc70986a8 100644 --- a/sys/dev/iicbus/pmic/act8846.c +++ b/sys/dev/iicbus/pmic/act8846.c @@ -226,11 +226,16 @@ static int act8846_detach(device_t dev) { struct act8846_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); LOCK_DESTROY(sc); - return (bus_generic_detach(dev)); + return (0); } static device_method_t act8846_methods[] = { diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c index 59ac6911c784..b339badad925 100644 --- a/sys/dev/mana/gdma_main.c +++ b/sys/dev/mana/gdma_main.c @@ -1879,6 +1879,11 @@ static int mana_gd_detach(device_t dev) { struct gdma_context *gc = device_get_softc(dev); + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); mana_remove(&gc->mana); @@ -1890,7 +1895,7 @@ mana_gd_detach(device_t dev) pci_disable_busmaster(dev); - return (bus_generic_detach(dev)); + return (0); } diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx.c b/sys/powerpc/mpc85xx/pci_mpc85xx.c index f4080ce3b75c..8e349df03a51 100644 --- a/sys/powerpc/mpc85xx/pci_mpc85xx.c +++ b/sys/powerpc/mpc85xx/pci_mpc85xx.c @@ -673,12 +673,17 @@ static int fsl_pcib_detach(device_t dev) { struct fsl_pcib_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); mtx_destroy(&sc->sc_cfg_mtx); - return (bus_generic_detach(dev)); + return (0); } static int diff --git a/sys/powerpc/powermac/cuda.c b/sys/powerpc/powermac/cuda.c index 4d120747e0f0..367eb7a059c2 100644 --- a/sys/powerpc/powermac/cuda.c +++ b/sys/powerpc/powermac/cuda.c @@ -259,6 +259,11 @@ cuda_attach(device_t dev) static int cuda_detach(device_t dev) { struct cuda_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -267,7 +272,7 @@ static int cuda_detach(device_t dev) { bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr); mtx_destroy(&sc->sc_mutex); - return (bus_generic_detach(dev)); + return (0); } static uint8_t diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c index 2d38545a7046..e0358c6f9887 100644 --- a/sys/powerpc/powermac/pmu.c +++ b/sys/powerpc/powermac/pmu.c @@ -524,6 +524,11 @@ static int pmu_detach(device_t dev) { struct pmu_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -535,7 +540,7 @@ pmu_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr); mtx_destroy(&sc->sc_mutex); - return (bus_generic_detach(dev)); + return (0); } static uint8_t