From nobody Fri Mar 4 10:29:29 2022 X-Original-To: dev-commits-src-branches@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 34F0219F4FFA; Fri, 4 Mar 2022 10:29:30 +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 4K93xk0vqQz4g4R; Fri, 4 Mar 2022 10:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646389770; 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=C+jsS865vtmXixd6ttHqd6KQtmY1fqqNP3y7HwKd/Yg=; b=nwb59dvUArBfCgbSVR8e/JPROMxqX9/OsqGUjrfw8IB+ZA4rW8SUA5486lRe7gkNvnAfs6 8pAWFCYaIP1yM82nFAzilBNz56PmeD9D5sToQY85gFrPyubxBEvzYFADk1bdLp/N2mrSpr Uoj8oWEqs1hCs4ZyZVkz56a6V9q++YwCjlEkMC4SHzfG0884Rd0DKzMsX8moVFmJbpuPw5 THnaQBhSlLtpXNps5LKlkth06Vx9rcY5N/kP8gcaXheBbzde/hiohXnf1FC3HOfWx3IF+u 0HlZg5l+GzMM/CBw11BlFOeo9gZ5S4wIzLVRBmq+LGFQRK9vtu5x6/3xn6n6vA== 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 F39D62589; Fri, 4 Mar 2022 10:29:29 +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 224ATTTD013467; Fri, 4 Mar 2022 10:29:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 224ATTnp013466; Fri, 4 Mar 2022 10:29:29 GMT (envelope-from git) Date: Fri, 4 Mar 2022 10:29:29 GMT Message-Id: <202203041029.224ATTnp013466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 66f5398552a9 - stable/13 - dwc: Release resources when attach fails List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 66f5398552a9ba58906f01b6acedab51fc04554d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646389770; 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=C+jsS865vtmXixd6ttHqd6KQtmY1fqqNP3y7HwKd/Yg=; b=lEgndCGMWeYDkPlxxWw7/5LjTQcJ6hs1+8ZU+Tv7QMzr/RTbe45Bup9WCv9qrusT+g7H1/ iCl87EvIcZXYldWClEoi5iHVnWMy1Do4f7v6nkmry2nU09DUGhtb9PMiZsQpIODyBobSss R7sz5tVKGSpE3UyZsGZKAJVNB5CUT+LK3PB1AtuaKUF606IkPtNuobJpyfxqMxyn0iMuE8 BPfb989egKvFzfDiYGoymzC5nror336JcqpGRbn4THeldXmp5/E7Cuz+ydRPuC/zgHJAWG m7vp/09wYlhB5TDQAuX2KfZkYKbtByIbcj9/gq8Pro/J5jc5MsdDOhqfPiLk+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646389770; a=rsa-sha256; cv=none; b=Ty3nCesIpZJFdlc1pIeXqArI96n/rhRL2IKSDNmdURM4Dcc8eml7DOdXcd9NTSaiZ4kvow tiwHQFi/6Z81DmqVJ0sftQ8kksUODg78sircB0in7YaFFykgbDw3b1BTDuU+USiMIbGHRU NPwe9rpa+9Er9dnNAG3Td+f9s/WA16Mf1ETVLxrhHxIOHxu6CGZWzdKPEMyOU0YITXMQBU rptt1lERhdTplpqiM+bFU2a0ZSPtJS6Pmh8C0ULWp7AbxgB1zEqRrWhpqBc3ar8+2ZIE3K 3BXXW1BO9owz8tctmICR3PMW3ku9YQp+C4F7d3C8r4lcRbI5TVrBY7U4vUkJcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=66f5398552a9ba58906f01b6acedab51fc04554d commit 66f5398552a9ba58906f01b6acedab51fc04554d Author: Emmanuel Vadot AuthorDate: 2022-02-22 08:53:11 +0000 Commit: Emmanuel Vadot CommitDate: 2022-03-04 10:29:13 +0000 dwc: Release resources when attach fails PR: 259282 MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 30f16ad460e2f9631484d04f067d80ee578473bc) --- 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 429e250f48e8..0704912b48ad 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -1619,6 +1619,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); } @@ -1634,6 +1635,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); } @@ -1654,8 +1656,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); @@ -1671,6 +1675,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); } @@ -1696,6 +1701,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);