From nobody Wed Feb 15 21:41:55 2023 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 4PHBNz2tZFz3rMhd; Wed, 15 Feb 2023 21:41:55 +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 4PHBNz2QBxz3Mtk; Wed, 15 Feb 2023 21:41:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676497315; 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=o8YidbFYu6UlCk8WJSpCuTtRlJ69yXLkx6W85XDqUFI=; b=sMnge4jM96YCZqGI6A2c5VnVezCIxGOGR5uT0QACWj367A1UH75HZylqs6k9HF+XMSB8Tm /uX/k8a/pY/qH32uTlbmEstX4z0W2MHpnaJJpqvvpTfSll1AfxnjgBtXWOIKpxY34T5qpi kxJXGTkdFCbxeadC/Y31xqPb6NMhQpiTcEE4jBuTbWm9tkGGhOOB3hdUUM6lINysF3tnRG m+Wd8CB9ZBrJ0EgsqGGkXusU1dCeB4AJakhWH1NY5BqeodDaFsqAU7Bn03IXnWgmWvOfAJ fbsMXncF4eopPHBQpwNkelhXjJnkHgZXW9KrKcR7MCrCi1qMSb4UWiNVWotXig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676497315; 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=o8YidbFYu6UlCk8WJSpCuTtRlJ69yXLkx6W85XDqUFI=; b=darTdEYc0NDyQJyl38Zj1GBtyLJAv88HzLNUTQ5CURhAmk5OVTSP1QTuAc929wAIlM3AgN sG4qy1SJ5bQiFiCfmMPmWjOQSYtZEvnGTj/ALXiBY5p/3HLo1kj+bo2MFl/1VuhpxsY1V/ AbAMOzRRA29G4y7tNZwESmDnNlUeCUMvisgb7J6rbqAWKIxtpi+6fVCe81VEtu8qJ/B7WC Q2dxEVebkKAJGxGPeLIdNuS78Rd9N6FE51J07Xc8qWF2upOhJKCnenSzLbYSGzounuFQt2 dor3VIKZ7FYW+3s/6/1TVEY1vWahjLdnRMIxaAUCX3jYrIXq1+T+92rlX3s3rQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676497315; a=rsa-sha256; cv=none; b=tJ7ea3opTTbZSJxEJOprglys8MOh5cai8HKLWCRHOawm1tDBSQRIqO8c543baugMRoPJZK pv5g92gn5pgJhC+vOMBwQICoFwKD5p4PE8boP44qOmkEQL2z06pv5HsaUQdnvXeMmDw1I0 cAV8Luf3b32RcNj5l4D0gVHMy7cO5dhmQJCET6l1AVOhQark+KAwmJRMpVYpl26HsxowvQ GFthp0o2XR9kfuDjprn+ZrOYiypXIvSpa3QSn/57YX2bhtAWQGhMxMzMlkXNYulEj4Y/uH Ke+u5CN4/2ASsHeE2+VX71pSJszWiIXFBS+zlXFitT8dj01Fg/J/EwtyjV5ZPg== 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 4PHBNz1TTszfwd; Wed, 15 Feb 2023 21:41:55 +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 31FLfths035124; Wed, 15 Feb 2023 21:41:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31FLft1Q035122; Wed, 15 Feb 2023 21:41:55 GMT (envelope-from git) Date: Wed, 15 Feb 2023 21:41:55 GMT Message-Id: <202302152141.31FLft1Q035122@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: d2070e5fa983 - main - cxgbe: Don't leak memory resource if t4iov attach fails. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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: d2070e5fa983281e94a338d6e87eb29c7dd28505 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d2070e5fa983281e94a338d6e87eb29c7dd28505 commit d2070e5fa983281e94a338d6e87eb29c7dd28505 Author: John Baldwin AuthorDate: 2023-02-15 21:34:00 +0000 Commit: John Baldwin CommitDate: 2023-02-15 21:34:00 +0000 cxgbe: Don't leak memory resource if t4iov attach fails. Co-authored by: np Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D38580 --- sys/dev/cxgbe/t4_iov.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/dev/cxgbe/t4_iov.c b/sys/dev/cxgbe/t4_iov.c index d3796d300947..ce9a97c69ed4 100644 --- a/sys/dev/cxgbe/t4_iov.c +++ b/sys/dev/cxgbe/t4_iov.c @@ -194,6 +194,7 @@ t4iov_attach(device_t dev) { struct t4iov_softc *sc; uint32_t pl_rev, whoami; + int error; sc = device_get_softc(dev); sc->sc_dev = dev; @@ -217,10 +218,18 @@ t4iov_attach(device_t dev) sc->sc_main = pci_find_dbsf(pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), 4); - if (sc->sc_main == NULL) + if (sc->sc_main == NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, + sc->regs_res); return (ENXIO); - if (T4_IS_MAIN_READY(sc->sc_main) == 0) - return (t4iov_attach_child(dev)); + } + if (T4_IS_MAIN_READY(sc->sc_main) == 0) { + error = t4iov_attach_child(dev); + if (error != 0) + bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, + sc->regs_res); + return (error); + } return (0); }