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 03340A00C5; Wed, 6 May 2020 18:28:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B6A71DA21; Wed, 6 May 2020 18:28:28 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 448921D901 for ; Wed, 6 May 2020 18:28:26 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 May 2020 19:28:21 +0300 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 046GSLPs025553; Wed, 6 May 2020 19:28:21 +0300 From: Michael Baum To: dev@dpdk.org Cc: Matan Azrad , Viacheslav Ovsiienko , stable@dpdk.org Date: Wed, 6 May 2020 16:27:54 +0000 Message-Id: <1588782474-17314-1-git-send-email-michaelba@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/mlx4: fix drop queue mem alloc failure handle 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" The function mlx4_drop_get() creates pointer to a struct mlx4_drop and if needed allocates by rte_malloc. If the allocation is failed the function goes to label “error”, and there does dereference to a null pointer. Skip resources cleaning when the memory allocation is failed. Coverity issue: 146206 Coverity issue: 146146 Fixes: d3a7e09234e4 ("net/mlx4: allocate drop flow resources on demand") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx4/mlx4_flow.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 793f0b0..2a86382 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -980,12 +980,13 @@ struct mlx4_drop { priv->drop = drop; return drop; error: - if (drop->qp) - claim_zero(mlx4_glue->destroy_qp(drop->qp)); - if (drop->cq) - claim_zero(mlx4_glue->destroy_cq(drop->cq)); - if (drop) + if (drop) { + if (drop->qp) + claim_zero(mlx4_glue->destroy_qp(drop->qp)); + if (drop->cq) + claim_zero(mlx4_glue->destroy_cq(drop->cq)); rte_free(drop); + } rte_errno = ENOMEM; return NULL; } -- 1.8.3.1