From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 622C6A0471 for ; Fri, 21 Jun 2019 18:48:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 59F6C1D548; Fri, 21 Jun 2019 18:48:33 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 6CF2F1D548 for ; Fri, 21 Jun 2019 18:48:32 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0F6222387F; Fri, 21 Jun 2019 16:48:31 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1DFE60BE0; Fri, 21 Jun 2019 16:48:22 +0000 (UTC) From: Kevin Traynor To: Dekel Peled Cc: Ori Kam , dpdk stable Date: Fri, 21 Jun 2019 17:45:53 +0100 Message-Id: <20190621164626.31219-9-ktraynor@redhat.com> In-Reply-To: <20190621164626.31219-1-ktraynor@redhat.com> References: <20190621164626.31219-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 21 Jun 2019 16:48:31 +0000 (UTC) Subject: [dpdk-stable] patch 'net/mlx5: fix memory free on queue create error' has been queued to LTS release 18.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/26/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/4abc36975cb000a215cf201f2c018d83e75d3f2d Thanks. Kevin Traynor --- >From 4abc36975cb000a215cf201f2c018d83e75d3f2d Mon Sep 17 00:00:00 2001 From: Dekel Peled Date: Mon, 20 May 2019 11:07:26 +0300 Subject: [PATCH] net/mlx5: fix memory free on queue create error [ upstream commit 9e444764487748d28adb9b57e75452ea8c3c9945 ] In function mlx5_rxq_ibv_new(), pointer *tmpl allocation is attempted at the start, but not validated or freed in case of error. In function mlx5_txq_ibv_new(), pointer *txq_ibv allocation is attempted at the start, but not freed in case of error. This patch adds pointers initialization, validation and freeing. Fixes: 09cb5b581762 ("net/mlx5: separate DPDK from verbs Rx queue objects") Fixes: faf2667fe8d5 ("net/mlx5: separate DPDK from verbs Tx queue objects") Signed-off-by: Dekel Peled Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_rxq.c | 22 +++++++++++++--------- drivers/net/mlx5/mlx5_txq.c | 4 +++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index f48b5512d..416c07342 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -778,5 +778,5 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) unsigned int cqe_n; unsigned int wqe_n = 1 << rxq_data->elts_n; - struct mlx5_rxq_ibv *tmpl; + struct mlx5_rxq_ibv *tmpl = NULL; struct mlx5dv_cq cq_info; struct mlx5dv_rwq rwq; @@ -1019,13 +1019,17 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) return tmpl; error: - ret = rte_errno; /* Save rte_errno before cleanup. */ - if (tmpl->wq) - claim_zero(mlx5_glue->destroy_wq(tmpl->wq)); - if (tmpl->cq) - claim_zero(mlx5_glue->destroy_cq(tmpl->cq)); - if (tmpl->channel) - claim_zero(mlx5_glue->destroy_comp_channel(tmpl->channel)); + if (tmpl) { + ret = rte_errno; /* Save rte_errno before cleanup. */ + if (tmpl->wq) + claim_zero(mlx5_glue->destroy_wq(tmpl->wq)); + if (tmpl->cq) + claim_zero(mlx5_glue->destroy_cq(tmpl->cq)); + if (tmpl->channel) + claim_zero(mlx5_glue->destroy_comp_channel + (tmpl->channel)); + rte_free(tmpl); + rte_errno = ret; /* Restore rte_errno. */ + } priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE; - rte_errno = ret; /* Restore rte_errno. */ return NULL; } diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index c5a3d1b4c..2971f9aa2 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -360,5 +360,5 @@ mlx5_txq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) container_of(txq_data, struct mlx5_txq_ctrl, txq); struct mlx5_txq_ibv tmpl; - struct mlx5_txq_ibv *txq_ibv; + struct mlx5_txq_ibv *txq_ibv = NULL; union { struct ibv_qp_init_attr_ex init; @@ -544,4 +544,6 @@ error: if (tmpl.qp) claim_zero(mlx5_glue->destroy_qp(tmpl.qp)); + if (txq_ibv) + rte_free(txq_ibv); priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE; rte_errno = ret; /* Restore rte_errno. */ -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-06-21 17:22:12.221669119 +0100 +++ 0009-net-mlx5-fix-memory-free-on-queue-create-error.patch 2019-06-21 17:22:11.719519217 +0100 @@ -1 +1 @@ -From 9e444764487748d28adb9b57e75452ea8c3c9945 Mon Sep 17 00:00:00 2001 +From 4abc36975cb000a215cf201f2c018d83e75d3f2d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 9e444764487748d28adb9b57e75452ea8c3c9945 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index 3330057fa..e04a4718e 100644 +index f48b5512d..416c07342 100644 @@ -28 +29 @@ -@@ -844,5 +844,5 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) +@@ -778,5 +778,5 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) @@ -35 +36 @@ -@@ -1085,13 +1085,17 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) +@@ -1019,13 +1019,17 @@ mlx5_rxq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) @@ -62 +63 @@ -index 50b1f810a..289024c4c 100644 +index c5a3d1b4c..2971f9aa2 100644 @@ -65 +66 @@ -@@ -402,5 +402,5 @@ mlx5_txq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) +@@ -360,5 +360,5 @@ mlx5_txq_ibv_new(struct rte_eth_dev *dev, uint16_t idx) @@ -72 +73 @@ -@@ -587,4 +587,6 @@ error: +@@ -544,4 +544,6 @@ error: