From nobody Wed Sep 06 21:56:40 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 4Rgx6J6qQfz4sJLW; Wed, 6 Sep 2023 21:56:40 +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 4Rgx6J67lfz3b9X; Wed, 6 Sep 2023 21:56:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037400; 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=E8NAOe8UQNyzXbgmrGbdAC8LZ+jlGkt4/tLOCawQUC0=; b=QoT3T7zjhkkCmIskQA3ahao5wO/cO+FCMfa7U66XJfayGgMvGnZ5jt+1tqH/D10KiOTJ2b s5hBlQM+ODIjK9reijHoe305VhMeunoBacidWgB2DrXYvWsigBy0Yhuiui59AFl64CQqxy tTXrLSsZGifY0b9P6bmq4U7uWdmWUUezhCsxMeo3rijtF2J4I03kbvqFAl68rjRdguJqXq tPgJ89SkzGQT9BUhLW4c2TVk9qDNC3w1W5Xtoi9lq7bXN9FrWCJVZ/Ra5HRJclrVRYtQRt tYCCjGrNmz5+VH85sZZKn+i58QUsXju23nxfW0OiysCrD0m0tYuD3CseTDluhg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694037400; a=rsa-sha256; cv=none; b=vMLF+xNAWC+gWCYUIeOCk+0nwLB1clXuzOWsoQNMIRdp0VUxaCFuAoih3RjNzemU/zvBGS M/L9E3RZCb6aiQdaaoOg5jMSfzYajVwaAOBE1FiNlFyn/lcH6wHbBAzLlk2rWNoZ2yH8Bj W6LJyIldBJrAJ1BxYywsV++zxX8v9bP5JfHiprkmwaNc2A6fKDs1kATMGT0MZo1M72FD2D uvLkWdeMLTFFp4OV7feDRXQRgw7WTVVDB0ObzYfecQH9gZ0ot/BOWmCsJYmtnax8kSo+9p QD8mRZlLBIcrv8+zn7CnFV+wLkZ63L+MS1WxCbUwTp6BuIMhsuhBeozAt3BGUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037400; 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=E8NAOe8UQNyzXbgmrGbdAC8LZ+jlGkt4/tLOCawQUC0=; b=qvUDBAAGtum431P++rAryYM0mTv1kmqoz/xD19gxzGaqo+i6lsJJTRHKs8uULrEFlEZybw FvvtZ/llyegJ5fu4S1xrs1CTZJBVIY+i41Y2+aGfu7HcZJTYFHktzSnlv+coYYJ6LRwG1T Q5VGKYq2HDYP+OxQr6qU+ydArj4fVJWtxsFnQpOWCcOKUcIjvxSZr3fY1oFpwra6zJh/67 oELKt10vGnsW6rIzcs/SghWKfYpPqkE8Xpt/KfzbfZIA3h8ECWBwvNqHi8n44CNhnPCiBk Z6dQBpj632eNXFmSrk9hFQmc1bx+g5k7Ywe2IR6fEv6P0qJn3MxCxF51uhc+Iw== 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 4Rgx6J4tNszZ6F; Wed, 6 Sep 2023 21:56:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 386LueZ6022769; Wed, 6 Sep 2023 21:56:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386Lueal022766; Wed, 6 Sep 2023 21:56:40 GMT (envelope-from git) Date: Wed, 6 Sep 2023 21:56:40 GMT Message-Id: <202309062156.386Lueal022766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: a3105e25800c - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: a3105e25800cfc8c8eccffb002cfbd2358a18ab1 Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a3105e25800cfc8c8eccffb002cfbd2358a18ab1 commit a3105e25800cfc8c8eccffb002cfbd2358a18ab1 Author: John Baldwin AuthorDate: 2023-02-15 21:34:00 +0000 Commit: John Baldwin CommitDate: 2023-09-06 21:56:09 +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 (cherry picked from commit d2070e5fa983281e94a338d6e87eb29c7dd28505) --- 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 ac58f9ca0a70..b063bda233b9 100644 --- a/sys/dev/cxgbe/t4_iov.c +++ b/sys/dev/cxgbe/t4_iov.c @@ -192,6 +192,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; @@ -215,10 +216,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); }