From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E2677A04DD; Wed, 28 Oct 2020 18:11:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5A7315928; Wed, 28 Oct 2020 18:11:17 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id B243B56A3 for ; Wed, 28 Oct 2020 18:11:15 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 28 Oct 2020 19:11:12 +0200 Received: from nvidia.com (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09SHBBGk023507; Wed, 28 Oct 2020 19:11:11 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, shahafs@nvidia.com, viacheslavo@nvidia.com, stable@dpdk.org Date: Wed, 28 Oct 2020 19:10:40 +0200 Message-Id: <20201028171040.6476-1-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 Subject: [dpdk-dev] [PATCH] mlx5/net: fix release of SQ resources in error flow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Fix in error flow in which the function mlx5_txq_release_devx_sq_resources is called twice by setting the release object to NULL after the first call The incorrect flow was introduced in the work done on generic object creation. Once an error flow inside mlx5_txq_create_devx_sq_resources occurs the function will call mlx5_txq_release_devx_sq_resources however the released pointers are not set to NULL after the release calls and undefined memory is released in the same call in mlx5_txq_release_devx_resources. This results in calls to MLX5_FREE with an already released memory addresses and assert in mlx5_release_dbr: EAL: Error: Invalid memory EAL: Error: Invalid memory PANIC in mlx5_txq_release_devx_sq_resources(): assert "(mlx5_release_dbr(&txq_obj->txq_ctrl->priv->dbrpgs, mlx5_os_get_umem_id (txq_obj->sq_dbrec_page->umem), txq_obj->sq_dbrec_offset)) == 0" failed The fix is setting the released pointers to NULL after the first release calls. Fixes: 86d259cec852 ("net/mlx5: separate Tx queue object creations") Cc: stable@dpdk.org Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_devx.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 11bda32557..5f5f2f2444 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -948,17 +948,25 @@ mlx5_txq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx) static void mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj) { - if (txq_obj->sq_devx) + if (txq_obj->sq_devx) { claim_zero(mlx5_devx_cmd_destroy(txq_obj->sq_devx)); - if (txq_obj->sq_umem) + txq_obj->sq_devx = NULL; + } + if (txq_obj->sq_umem) { claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem)); - if (txq_obj->sq_buf) + txq_obj->sq_umem = NULL; + } + if (txq_obj->sq_buf) { mlx5_free(txq_obj->sq_buf); - if (txq_obj->sq_dbrec_page) + txq_obj->sq_buf = NULL; + } + if (txq_obj->sq_dbrec_page) { claim_zero(mlx5_release_dbr(&txq_obj->txq_ctrl->priv->dbrpgs, mlx5_os_get_umem_id (txq_obj->sq_dbrec_page->umem), txq_obj->sq_dbrec_offset)); + txq_obj->sq_dbrec_page = NULL; + } } /** -- 2.16.1.windows.4