From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5C42A0C58; Tue, 31 Aug 2021 22:40:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D541141137; Tue, 31 Aug 2021 22:40:15 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2069.outbound.protection.outlook.com [40.107.92.69]) by mails.dpdk.org (Postfix) with ESMTP id 569534013F; Tue, 31 Aug 2021 22:40:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TI7eZxbDROQGhFmG8bjbvgmasRja7DkzFCLhvegVUASTrTVnLkl9ex716Z+VArrQe06RiU6oLcRdXI14jaenakey6p73xqwwcRKe9W7LH+zn/e+1xIRK/nKcKr0MJNIoXSYqmd8YP3nz3vLhTiU39JX0vEyGRER+YrBH4bcARO0P4Zk+ibfCC7YhOTMhROjVLXZVR3kbkM8Q5yuGH5pbdAflbmc+6sB43t2qMEJNgIS8V97Pat9uU9B3Ea3e4vN5Wb2MnfQ3SgA0mCIs/c4aT1cAO+b0EQIHbuMlRE04WhH7Os7rOTUhpMySe4nXECj+38UPeLYZgWcM7CGuF/l3xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4DmU/jM9NGu3etcHe5efnYk4esdnx9pVBi4hkEgp2qM=; b=lPh0GcpbVYOIrMjhV5EpRH+SVUb75P8V0lz0nP2BRsyvt5msJr4Ezu7Xl3SWMNNsou3evCx83Lylc9S/O04W+Ty+vRrpQ0zL2p4kA0BruB9RwtM1DtaicJ6ZUa1AWOiM6baOUwBa+4vfaBa27XhclOmrI7J2kAFaIhVkfnPTTuayPcbAXd7kMUGBFtcLBRY7wbdFWo+88hkBl3w1wtePYiV68Dm8M8Y7JouHWpaUFjQUk3SM20miOdoPyYaN4Pd6Mw6tLg/U3OYMPvsjY2oR0yDXYdAIWRy9ASQmWNO3RjmRrcsLK0ueqa2kjuOLOvyVXhFGp2strPxEloWX4hyTnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4DmU/jM9NGu3etcHe5efnYk4esdnx9pVBi4hkEgp2qM=; b=MgWUKraIyXNJthQ4/nkdrnrltKqjQmVyS45aCmSRdc1W0we33yvgITTYx4JV/KGgVsPfpWLs5XfOp6vHf0nKsC2OASY3xb9bLm4uaxSw8ub6UTPA4XCacmSYHgiKiGRrODKXXiSNtgmoQygjWkXW88hAZBE5nNWkmMvb/SEvxQXj6S/reJgunCJWuZP0Tz81sVvx2vMrn8wriDY2zaqFFF4J3NsMucaB3RVoUE9z7cpaFHHuvdSBSgXT7EU5QOQLzESULPSQa5AHvr5u7E+RHX17fiAttxXqmhF5cp/EOTouZTiYxTfkUrkq3pYpCIy4kOfuGKAGBDNlzxaGV7QCRQ== Received: from MWHPR07CA0014.namprd07.prod.outlook.com (2603:10b6:300:116::24) by DM6PR12MB4235.namprd12.prod.outlook.com (2603:10b6:5:220::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17; Tue, 31 Aug 2021 20:40:12 +0000 Received: from CO1NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:300:116:cafe::30) by MWHPR07CA0014.outlook.office365.com (2603:10b6:300:116::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Tue, 31 Aug 2021 20:40:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT007.mail.protection.outlook.com (10.13.174.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 31 Aug 2021 20:40:10 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 20:40:03 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 20:40:02 +0000 From: Michael Baum To: CC: Matan Azrad , Date: Tue, 31 Aug 2021 23:39:41 +0300 Message-ID: <20210831203941.3411351-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33f7ace5-08a7-41af-92b6-08d96cbf86e2 X-MS-TrafficTypeDiagnostic: DM6PR12MB4235: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:386; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yJwJSSAvrvAfM77hMiglpEpM/Hg1YwZzH5UsH/WPblcu4ucRwV8VIS2PPdhR5ctzP9pF3N/dIGIhDwaKv/8MAGaP1aY3X3ZHrRr5emlXgayosVafIY5FzFXcgNo2lV0NtyxXwSD2l0GBq+psx01gK8g+RgPwGDBjkfi99cgsLz5Hr1qmXe1By7QWCgjLEK3Ewc723edI3S3EYm2TVwV+jOIsSDEc3lJKnCq8W/HpbcGRijk+MQnDoCXRGPZ9+T3qAZ1cw3lQLtzeRoaB+N5Kr51yz+A9Bnp7k6+OQulrBpxp3Jmf3pBsLD6xEU9vsMBdv/LpQynVEWOLWQ+eZfbmfxDO73JpBXncqL8VpI9gPTLXT6Bv2roLUiRnt/n7eKoZslMp+muDF26wIZgklrPp2hJix92SIror+o0KavPv+s84592Lqi2+hDG3G9PTS2VaO9BsFF87Y2MwJo5r/B6faljg5bC9srYImNNdFFpiVLaPlIiQUpWkPdQUvTx2QYvWf/jp0gGHpMtw2QLB/wENecrjWyNmfEM4bXUv+FSkPInuNfX5VyH9o9Pf+S3NMNc7pfJ2t3Lj4HDApaRL8bJHkEfyM9Rm6RWoT4vvjelWrW4QpUJxvadGe9FEPRAE4nnmhiCVXF3DCJXN0Msj42L7G8xbsTxpDlsWDumOqPCQfquI+ErJaKpvxZ+i/Rit1qG7FEqX3OU//KK1iYJ0wr8qbg== X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(39860400002)(136003)(396003)(376002)(46966006)(36840700001)(2906002)(426003)(82310400003)(478600001)(36756003)(6666004)(8936002)(316002)(70586007)(1076003)(8676002)(4326008)(450100002)(70206006)(5660300002)(7696005)(336012)(26005)(16526019)(186003)(2616005)(47076005)(36906005)(82740400003)(54906003)(356005)(6286002)(55016002)(7636003)(83380400001)(36860700001)(6916009)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 20:40:10.6165 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33f7ace5-08a7-41af-92b6-08d96cbf86e2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4235 Subject: [dpdk-dev] [PATCH] compress/mlx5: fix QP setup error flow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The QP setup function allocates buffer for its opaque MR and register it into MR structure. After buffer alloction and before MR registration, it tries allocate MR Btree. When the MR Btree allocation fails, the buffer was not freed what caused a memory leak. Allocate the MR Btree before buffer alloction. Fixes: 0165bccdb45f ("compress/mlx5: add memory region management") Cc: stable@dpdk.org Signed-off-by: Michael Baum --- drivers/compress/mlx5/mlx5_compress.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 883e720ec1..c5e0a83a8c 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -207,6 +207,13 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, return -rte_errno; } dev->data->queue_pairs[qp_id] = qp; + if (mlx5_mr_btree_init(&qp->mr_ctrl.cache_bh, MLX5_MR_BTREE_CACHE_N, + priv->dev_config.socket_id)) { + DRV_LOG(ERR, "Cannot allocate MR Btree for qp %u.", + (uint32_t)qp_id); + rte_errno = ENOMEM; + goto err; + } opaq_buf = rte_calloc(__func__, (size_t)1 << log_ops_n, sizeof(struct mlx5_gga_compress_opaque), sizeof(struct mlx5_gga_compress_opaque)); @@ -215,13 +222,6 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, rte_errno = ENOMEM; goto err; } - if (mlx5_mr_btree_init(&qp->mr_ctrl.cache_bh, MLX5_MR_BTREE_CACHE_N, - priv->dev_config.socket_id)) { - DRV_LOG(ERR, "Cannot allocate MR Btree for qp %u.", - (uint32_t)qp_id); - rte_errno = ENOMEM; - goto err; - } qp->entries_n = 1 << log_ops_n; qp->socket_id = socket_id; qp->qp_id = qp_id; -- 2.25.1