From nobody Thu Jan 02 18:28:26 2025 X-Original-To: dev-commits-src-main@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 4YPFZg1BQfz5jnZ7; Thu, 02 Jan 2025 18:28:27 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YPFZf6qz6z4vCX; Thu, 2 Jan 2025 18:28:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842507; 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=aoLOD45jXA3sJNKoU/pda01BcbkIF9QyX2b48vLrwJU=; b=l6NVKC7KH4M2ok13PpTGDu0AfMclhg2ku4u/lIhcZAb69/yT2JUzMIYzugWmgzY9UVfYZE 6fs74RPH7xBAsnx0tkrSypkDYvmptjjxM3Wdwo3KqIQ3NEDaEFp2al4HZrzsUG+QkFZdbi BqsljfCv39bkoRFvlmUwZ67Hmv/2eBQfItqldv2VJZhP8H7smUX/hqFLbeAnnCkzHXgODS gmZCzlpA6pi7LZHUWgoFhvyWPw6uKT2eWVkjPovf4l+BGXB9YBl/Qih1svf35HnI0jkkRr +pJL0kZ4twm5QcjgdVB3l6nFkwUxeCifQ+5gmsie1Ju25V3Mn+E9J9CMLyhfLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842507; 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=aoLOD45jXA3sJNKoU/pda01BcbkIF9QyX2b48vLrwJU=; b=cOMclLIyAuy4h2G4hvYOZBxsv6y+rV1f7tgvGBp85/OpkeLgZLtKI9x5PQOEvi38AAqmQ0 xuwBORWrcSbIg+qYjLErRcXH9DY0qbHx1oFpo5ZpK2xUBgRNUL4MWILbPT17lbvG7FZVHc Ila/Y20Nrry3k3IZqaEi8Hyu3Z6oCNiZyoHsVZDWbYzNqgabtGv1//F+DW98M4wMV6Ma3F 0pPb30TZvqPi8s4IZfwVGmfHs+t1hmiLB4yXM3vLenqkFxx8qCR8ZYCS7PvIn6G9HAPbd5 OMh140sJ9xmn1GjYRk/p/eW3d2JI5yiymk2DCzkIJatrsHRrTyRs+xK6QRsZtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735842507; a=rsa-sha256; cv=none; b=cD7lOw5ZHGhf0UAZtiueVsrnpqfKPH62FCGiWL9rscoGefwRn5eShjwMKQB8uyEaA2bwit 5qUUrDKoj0xu854xDEHrXmXuNexx1SxyPdZlbhZq7Jlja47d2DQWprljAbOQujNeZfxo8Y hN0p44IavF5f2FVtD2t0pHe7QRA5JYyPvtRQxksRlrMzyOscmgB4vY97oc2RxrVXlvfQb2 eYy+v5ih20UvynU0pNZP+73KWQZzATS+OVheNBpBDRyTy+LP5HlpDqMfmT5e9vsCFJvAI9 fbrMPaRkRyvM9eOQKPSFk6NMsEHYpr7aDr0YH9uFkDeO3/u4Rv7IsEYQtORkbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YPFZf6JHBzp58; Thu, 02 Jan 2025 18:28:26 +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 502ISQks066478; Thu, 2 Jan 2025 18:28:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 502ISQV9066475; Thu, 2 Jan 2025 18:28:26 GMT (envelope-from git) Date: Thu, 2 Jan 2025 18:28:26 GMT Message-Id: <202501021828.502ISQV9066475@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: 64d1a02e4e1a - main - Check for errors from bus_generic_detach in various drivers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 64d1a02e4e1a5f561d03b2bbc9c20dad255e79e8 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=64d1a02e4e1a5f561d03b2bbc9c20dad255e79e8 commit 64d1a02e4e1a5f561d03b2bbc9c20dad255e79e8 Author: John Baldwin AuthorDate: 2025-01-02 18:23:41 +0000 Commit: John Baldwin CommitDate: 2025-01-02 18:23:41 +0000 Check for errors from bus_generic_detach in various drivers In some cases, move the call to bus_generic_detach earlier so that any detach failures from child devices do not leave the parent device partially detached. Differential Revision: https://reviews.freebsd.org/D47966 --- sys/arm/nvidia/tegra_sdhci.c | 6 +++++- sys/arm/ti/cpsw/if_cpsw.c | 7 +++++-- sys/arm/ti/ti_spi.c | 7 +++++-- sys/arm/xilinx/zy7_devcfg.c | 8 +++++--- sys/arm/xilinx/zy7_qspi.c | 6 ++++-- sys/arm/xilinx/zy7_slcr.c | 5 ++++- sys/arm/xilinx/zy7_spi.c | 6 ++++-- sys/dev/etherswitch/felix/felix.c | 5 +++-- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/sys/arm/nvidia/tegra_sdhci.c b/sys/arm/nvidia/tegra_sdhci.c index 3bd9a9bb4632..fa6810b655c6 100644 --- a/sys/arm/nvidia/tegra_sdhci.c +++ b/sys/arm/nvidia/tegra_sdhci.c @@ -417,8 +417,12 @@ tegra_sdhci_detach(device_t dev) { struct tegra_sdhci_softc *sc = device_get_softc(dev); struct sdhci_slot *slot = &sc->slot; + int error; + + error = bus_detach_children(dev); + if (error != 0) + return (error); - bus_detach_children(dev); sdhci_fdt_gpio_teardown(sc->gpio); clk_release(sc->clk); bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index 9fc3f414477b..ea8f9c18490e 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -1085,6 +1085,11 @@ static int cpswp_detach(device_t dev) { struct cpswp_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); CPSW_DEBUGF(sc->swsc, ("")); @@ -1096,8 +1101,6 @@ cpswp_detach(device_t dev) callout_drain(&sc->mii_callout); } - bus_generic_detach(dev); - if_free(sc->ifp); mtx_destroy(&sc->lock); diff --git a/sys/arm/ti/ti_spi.c b/sys/arm/ti/ti_spi.c index 26d6691e5bb5..fd0e0b085363 100644 --- a/sys/arm/ti/ti_spi.c +++ b/sys/arm/ti/ti_spi.c @@ -273,6 +273,11 @@ static int ti_spi_detach(device_t dev) { struct ti_spi_softc *sc; + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -283,8 +288,6 @@ ti_spi_detach(device_t dev) /* Reset controller. */ TI_SPI_WRITE(sc, MCSPI_SYSCONFIG, MCSPI_SYSCONFIG_SOFTRESET); - bus_generic_detach(dev); - mtx_destroy(&sc->sc_mtx); if (sc->sc_intrhand) bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand); diff --git a/sys/arm/xilinx/zy7_devcfg.c b/sys/arm/xilinx/zy7_devcfg.c index 1cb7ff9168cf..6df0fba1f56a 100644 --- a/sys/arm/xilinx/zy7_devcfg.c +++ b/sys/arm/xilinx/zy7_devcfg.c @@ -791,15 +791,17 @@ static int zy7_devcfg_detach(device_t dev) { struct zy7_devcfg_softc *sc = device_get_softc(dev); + int error; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); if (sc->sysctl_tree_top != NULL) { sysctl_ctx_free(&sc->sysctl_tree); sc->sysctl_tree_top = NULL; } - if (device_is_attached(dev)) - bus_generic_detach(dev); - /* Get rid of /dev/devcfg0. */ if (sc->sc_ctl_dev != NULL) destroy_dev(sc->sc_ctl_dev); diff --git a/sys/arm/xilinx/zy7_qspi.c b/sys/arm/xilinx/zy7_qspi.c index 53559571f7db..49d4cafd8d61 100644 --- a/sys/arm/xilinx/zy7_qspi.c +++ b/sys/arm/xilinx/zy7_qspi.c @@ -612,9 +612,11 @@ static int zy7_qspi_detach(device_t dev) { struct zy7_qspi_softc *sc = device_get_softc(dev); + int error; - if (device_is_attached(dev)) - bus_generic_detach(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); /* Disable hardware. */ if (sc->mem_res != NULL) { diff --git a/sys/arm/xilinx/zy7_slcr.c b/sys/arm/xilinx/zy7_slcr.c index 755b5d4806ed..a46ccb59a07b 100644 --- a/sys/arm/xilinx/zy7_slcr.c +++ b/sys/arm/xilinx/zy7_slcr.c @@ -673,8 +673,11 @@ static int zy7_slcr_detach(device_t dev) { struct zy7_slcr_softc *sc = device_get_softc(dev); + int error; - bus_generic_detach(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); /* Release memory resource. */ if (sc->mem_res != NULL) diff --git a/sys/arm/xilinx/zy7_spi.c b/sys/arm/xilinx/zy7_spi.c index d032deabf8b7..bb5bb7f46767 100644 --- a/sys/arm/xilinx/zy7_spi.c +++ b/sys/arm/xilinx/zy7_spi.c @@ -448,9 +448,11 @@ static int zy7_spi_detach(device_t dev) { struct zy7_spi_softc *sc = device_get_softc(dev); + int error; - if (device_is_attached(dev)) - bus_generic_detach(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); /* Disable hardware. */ if (sc->mem_res != NULL) { diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c index b6fb8cbb67c8..098767ee063e 100644 --- a/sys/dev/etherswitch/felix/felix.c +++ b/sys/dev/etherswitch/felix/felix.c @@ -480,9 +480,10 @@ felix_detach(device_t dev) int error; int i; - error = 0; sc = device_get_softc(dev); - bus_generic_detach(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); mtx_lock(&sc->mtx); callout_stop(&sc->tick_callout);