From nobody Tue Feb 22 09:02:08 2022 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 1568419DA020; Tue, 22 Feb 2022 09:02:09 +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 4K2tTX6NYQz3rdh; Tue, 22 Feb 2022 09:02:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645520528; 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=uD6LkT6iI/66moixiR0IjwCM1foxKeNpW1V2L9OEmEY=; b=DtYqrRpYPccCbwc69VFW/BF1piLs1Kq9rAnM7NgpA66DW+AxnPSjwbcC2+NCx7H4WWQD4i ZREgqwQ0Jn13Moutv9FU0shL2vl+9GfyQ8P0Lprh6jGb4e1Y6vc0AvsxAJWlTFSr2k86s+ 10MMs6cwxBmP/dS1sorY+SKKyQNy2C6HxUedyWliw7O0Q/UC6RyBMP+bjDMj9FFYVRiPAf XnJtPxRuKkXqyNBTD8hGV+yAwl3fJ0Sc5UssVBhnLKUM2w1OEG+WNgTJIU+gkzjvmdUS0O XiLNKkApJbZGcDFCXM3A/gvEb8YPw/dadl9bFJmQsBWD7zGeru5YHOU7dFI7eA== 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 B54F321586; Tue, 22 Feb 2022 09:02:08 +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 21M928vP051670; Tue, 22 Feb 2022 09:02:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21M928Qf051669; Tue, 22 Feb 2022 09:02:08 GMT (envelope-from git) Date: Tue, 22 Feb 2022 09:02:08 GMT Message-Id: <202202220902.21M928Qf051669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 30f16ad460e2 - main - dwc: Release resources when attach fails 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: 30f16ad460e2f9631484d04f067d80ee578473bc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645520528; 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=uD6LkT6iI/66moixiR0IjwCM1foxKeNpW1V2L9OEmEY=; b=iJ2ESMrePb0mJoDsdfG+lhFOeAFu3ge0SJhUVZrq8oMTK9o+1U+QWhcNvB1/g1rQXWMlMt 1hmjA1wRBNY25bmVk/zR6RwtzLHUqfK9XXjbfuVynCn5IkWAmdixmzaSpi2q0XGCpaTv4i /SjmLSij+emEd+Pd/AS1GttRsPq3tVu2gWypTL871/tdPlK3KXE8JPyPi093fg/Mg44Y5U qlKnhPMIOU/O3qhvF/JRuDMLDkf//4eple3aiOcDFwEVca1ANBl86d9gKjKtLICK+NApPt YS61f5iyRxDJoEVqqaUzbb7qcUh9XXSj2AQd5bAThczWeScpSmZoDyRKbe92nQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645520528; a=rsa-sha256; cv=none; b=fuSgkFvY+awR0FwQpGe+ku2tFot+lx0N7viZtSngfCz3ImKnNHizRS1O19HexyGvFHeH+a 0v3XpLA3jfB4GXgmEQIU1NhOLZ236rnJbXeGqXr6bkWCjAdgXYgN9Y5n4CjgEh3VgVhp2S KoIDs7y/ewjBODeVQQs19xn+RjhmBsfeCVVULRklabZr9Aa5uMr7iTskSED3+PTA6rqDOR 2c7pYDZuRL/d2Kr61ePyXAjuEACV4ocr2SLRnr786bXkzJHFAtl2trumgi/CIkM1UZVRpV FBYr3MCsfXQeAI6B7If2uZq80W3ZD8fiAIVH/K8p+EYOwuf83PidC4GEgg6XYA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=30f16ad460e2f9631484d04f067d80ee578473bc commit 30f16ad460e2f9631484d04f067d80ee578473bc Author: Emmanuel Vadot AuthorDate: 2022-02-22 08:53:11 +0000 Commit: Emmanuel Vadot CommitDate: 2022-02-22 09:01:54 +0000 dwc: Release resources when attach fails PR: 259282 MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/dev/dwc/if_dwc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 703c210a8f87..8bc0c0e7b6c3 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -1611,6 +1611,7 @@ dwc_attach(device_t dev) /* Reset the PHY if needed */ if (dwc_reset(dev) != 0) { device_printf(dev, "Can't reset the PHY\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1626,6 +1627,7 @@ dwc_attach(device_t dev) } if (i >= MAC_RESET_TIMEOUT) { device_printf(sc->dev, "Can't reset DWC.\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1646,8 +1648,10 @@ dwc_attach(device_t dev) reg &= ~(MODE_ST | MODE_SR); WRITE4(sc, OPERATION_MODE, reg); - if (setup_dma(sc)) - return (ENXIO); + if (setup_dma(sc)) { + bus_release_resources(dev, dwc_spec, sc->res); + return (ENXIO); + } /* Setup addresses */ WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr); @@ -1663,6 +1667,7 @@ dwc_attach(device_t dev) NULL, dwc_intr, sc, &sc->intr_cookie); if (error != 0) { device_printf(dev, "could not setup interrupt handler.\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1688,6 +1693,8 @@ dwc_attach(device_t dev) if (error != 0) { device_printf(dev, "PHY attach failed\n"); + bus_teardown_intr(dev, sc->res[1], sc->intr_cookie); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } sc->mii_softc = device_get_softc(sc->miibus);