From patchwork Wed Jun 19 09:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asaf Penso X-Patchwork-Id: 54950 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F59D1C2C5; Wed, 19 Jun 2019 11:46:36 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 694241C2BA; Wed, 19 Jun 2019 11:46:35 +0200 (CEST) From: Asaf Penso To: yskoh@mellanox.com, shahafs@mellanox.com Cc: dev@dpdk.org, stable@dpdk.org Date: Wed, 19 Jun 2019 09:46:24 +0000 Message-Id: <1560937584-447773-1-git-send-email-asafp@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix check for rte calloc return value 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" rte_calloc functions returns a non-null pointer in case of success and null pointer in case of failure. The return value should be checked and the function flow should take that into consideration. This patch adds a check for rte_calloc return value in function flow_list_create. Fixes: 84c406e7 ("net/mlx5: add flow translate function") Cc: stable@dpdk.org Signed-off-by: Asaf Penso Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 9887018..a5821e5 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2092,6 +2092,10 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, else flow_size += RTE_ALIGN_CEIL(sizeof(uint16_t), sizeof(void *)); flow = rte_calloc(__func__, 1, flow_size, 0); + if (!flow) { + rte_errno = ENOMEM; + return NULL; + } flow->drv_type = flow_get_drv_type(dev, attr); flow->ingress = attr->ingress; flow->transfer = attr->transfer;