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 566DEA0518 for ; Fri, 24 Jul 2020 14:02:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 49A141C010; Fri, 24 Jul 2020 14:02:59 +0200 (CEST) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 3E4A91C010 for ; Fri, 24 Jul 2020 14:02:58 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id j18so7732221wmi.3 for ; Fri, 24 Jul 2020 05:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+jgYkZVriwZs/xdDZtS7FfUG+qA2F1qDNYQDsetBT/M=; b=WC/rfKe0U9tCqas8XfIL94Ks7hc7OU1NwMkJOYokJxbSLpyqI8A5OmejUJ2vtWqbOV DuYWsQlD/cFAj+tHa6JCO7hz+slNswkbyGezZNieO3YxUNSjte2S35o0nuMav29nnrPJ K51i7l+kWMew3NNdqB7Q+uTQdq1wxYObPZ7bEzhGAkt5eonkBoOGooBKdw5OgI/FVlSk gRnK7fDTCIv71yqeM/QBycJM6dtkftkP1NNpa8SV2jRCcvbSq3QaqAI189NlEkrbUMrS TLIhdxxMDrL17I6O9GUyxbvhIGFYXW39rfX7TO60e+04+asExi5FBoPJDxhDVpzKUv+V MxXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+jgYkZVriwZs/xdDZtS7FfUG+qA2F1qDNYQDsetBT/M=; b=HVX7tNmEZ3H/uJkgrWY6P/d3scl6kmUNk8PCIOXNYfjeotitBIXuIoCeUqj6X2ww0R 9aRNQ5R1pj+7zBRAfe1yPtAER9PzpfkHQNWy9g33gW7E9gI0QNRkvnCJu/93b75r9DRS eRBgRs05luy6b8HfESh0ScIgMApdkYLhZZ8p7EjE8tfYNr46nbnC8gRjLzrLKJEJxZqj giV0h8eOqs94Ny0pToaYYvWCXMtGGhRS/K1duF9PvDaNAifkZXTOAIwXmjE0F9bibjJn TxxKf2DX3DwSjhaJSjwptSfC18/7BPvbFD0UxarZutV/aE4FCWwvO5xSLXnwN8e+3DxK O7EQ== X-Gm-Message-State: AOAM5326zCURZbb2rC0kncy/oMIPpiZiIvAZYZDO76vqRhXeOJj4Njrw v2xZxaj/1FWNEJ80VTQuP3w= X-Google-Smtp-Source: ABdhPJwHiN4iZgoH7u+rVYxpkQlzwE0XSuzFUgSTe1CMOMuBgjVi4i06ruyjxgYZQCi9x3waz4Hzng== X-Received: by 2002:a7b:c936:: with SMTP id h22mr8015362wml.114.1595592177904; Fri, 24 Jul 2020 05:02:57 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id n16sm6655434wmc.40.2020.07.24.05.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:02:56 -0700 (PDT) From: luca.boccassi@gmail.com To: Qi Zhang Cc: Surabhi Boob , Paul M Stillwell Jr , Qiming Yang , dpdk stable Date: Fri, 24 Jul 2020 12:57:54 +0100 Message-Id: <20200724120030.1863487-36-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724120030.1863487-1-luca.boccassi@gmail.com> References: <20200724120030.1863487-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/ice/base: fix memory leak on error path' has been queued to stable release 19.11.4 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 stable release 19.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/20. 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. Thanks. Luca Boccassi --- >From 26c98b7ec335eb0e3e1d0146e798e53f88f36b0d Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Mon, 15 Jun 2020 10:04:59 +0800 Subject: [PATCH] net/ice/base: fix memory leak on error path [ upstream commit be45049b3c4340499dad5648f455f7b443975671 ] Handles memory leaks during control queue initialization and buffer allocation failures. The MACRO - ICE_FREE_CQ_BUFS is modified to re-use for this fix. Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information") Signed-off-by: Surabhi Boob Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_controlq.c | 39 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c index feffb5198..0b651e7db 100644 --- a/drivers/net/ice/base/ice_controlq.c +++ b/drivers/net/ice/base/ice_controlq.c @@ -180,7 +180,9 @@ unwind_alloc_rq_bufs: i--; for (; i >= 0; i--) ice_free_dma_mem(hw, &cq->rq.r.rq_bi[i]); + cq->rq.r.rq_bi = NULL; ice_free(hw, cq->rq.dma_head); + cq->rq.dma_head = NULL; return ICE_ERR_NO_MEMORY; } @@ -218,7 +220,9 @@ unwind_alloc_sq_bufs: i--; for (; i >= 0; i--) ice_free_dma_mem(hw, &cq->sq.r.sq_bi[i]); + cq->sq.r.sq_bi = NULL; ice_free(hw, cq->sq.dma_head); + cq->sq.dma_head = NULL; return ICE_ERR_NO_MEMORY; } @@ -277,6 +281,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq) return ICE_SUCCESS; } +#define ICE_FREE_CQ_BUFS(hw, qi, ring) \ +do { \ + /* free descriptors */ \ + if ((qi)->ring.r.ring##_bi) { \ + int i; \ + \ + for (i = 0; i < (qi)->num_##ring##_entries; i++) \ + if ((qi)->ring.r.ring##_bi[i].pa) \ + ice_free_dma_mem((hw), \ + &(qi)->ring.r.ring##_bi[i]); \ + } \ + /* free the buffer info list */ \ + if ((qi)->ring.cmd_buf) \ + ice_free(hw, (qi)->ring.cmd_buf); \ + /* free DMA head */ \ + ice_free(hw, (qi)->ring.dma_head); \ +} while (0) + /** * ice_init_sq - main initialization routine for Control ATQ * @hw: pointer to the hardware structure @@ -332,6 +354,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) goto init_ctrlq_exit; init_ctrlq_free_rings: + ICE_FREE_CQ_BUFS(hw, cq, sq); ice_free_cq_ring(hw, &cq->sq); init_ctrlq_exit: @@ -393,27 +416,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq) goto init_ctrlq_exit; init_ctrlq_free_rings: + ICE_FREE_CQ_BUFS(hw, cq, rq); ice_free_cq_ring(hw, &cq->rq); init_ctrlq_exit: return ret_code; } -#define ICE_FREE_CQ_BUFS(hw, qi, ring) \ -do { \ - int i; \ - /* free descriptors */ \ - for (i = 0; i < (qi)->num_##ring##_entries; i++) \ - if ((qi)->ring.r.ring##_bi[i].pa) \ - ice_free_dma_mem((hw), \ - &(qi)->ring.r.ring##_bi[i]); \ - /* free the buffer info list */ \ - if ((qi)->ring.cmd_buf) \ - ice_free(hw, (qi)->ring.cmd_buf); \ - /* free DMA head */ \ - ice_free(hw, (qi)->ring.dma_head); \ -} while (0) - /** * ice_shutdown_sq - shutdown the Control ATQ * @hw: pointer to the hardware structure -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-07-24 12:53:50.001747359 +0100 +++ 0036-net-ice-base-fix-memory-leak-on-error-path.patch 2020-07-24 12:53:48.239005565 +0100 @@ -1,14 +1,15 @@ -From be45049b3c4340499dad5648f455f7b443975671 Mon Sep 17 00:00:00 2001 +From 26c98b7ec335eb0e3e1d0146e798e53f88f36b0d Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Mon, 15 Jun 2020 10:04:59 +0800 Subject: [PATCH] net/ice/base: fix memory leak on error path +[ upstream commit be45049b3c4340499dad5648f455f7b443975671 ] + Handles memory leaks during control queue initialization and buffer allocation failures. The MACRO - ICE_FREE_CQ_BUFS is modified to re-use for this fix. Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information") -Cc: stable@dpdk.org Signed-off-by: Surabhi Boob Signed-off-by: Paul M Stillwell Jr @@ -19,10 +20,10 @@ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c -index 3ef86fa03..f278ef636 100644 +index feffb5198..0b651e7db 100644 --- a/drivers/net/ice/base/ice_controlq.c +++ b/drivers/net/ice/base/ice_controlq.c -@@ -182,7 +182,9 @@ unwind_alloc_rq_bufs: +@@ -180,7 +180,9 @@ unwind_alloc_rq_bufs: i--; for (; i >= 0; i--) ice_free_dma_mem(hw, &cq->rq.r.rq_bi[i]); @@ -32,7 +33,7 @@ return ICE_ERR_NO_MEMORY; } -@@ -220,7 +222,9 @@ unwind_alloc_sq_bufs: +@@ -218,7 +220,9 @@ unwind_alloc_sq_bufs: i--; for (; i >= 0; i--) ice_free_dma_mem(hw, &cq->sq.r.sq_bi[i]); @@ -42,7 +43,7 @@ return ICE_ERR_NO_MEMORY; } -@@ -279,6 +283,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq) +@@ -277,6 +281,24 @@ ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq) return ICE_SUCCESS; } @@ -67,7 +68,7 @@ /** * ice_init_sq - main initialization routine for Control ATQ * @hw: pointer to the hardware structure -@@ -334,6 +356,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) +@@ -332,6 +354,7 @@ static enum ice_status ice_init_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) goto init_ctrlq_exit; init_ctrlq_free_rings: @@ -75,7 +76,7 @@ ice_free_cq_ring(hw, &cq->sq); init_ctrlq_exit: -@@ -395,27 +418,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq) +@@ -393,27 +416,13 @@ static enum ice_status ice_init_rq(struct ice_hw *hw, struct ice_ctl_q_info *cq) goto init_ctrlq_exit; init_ctrlq_free_rings: