From 3f22e3153fb5bd1ae2eebfa77678117eb15b33d8 Mon Sep 17 00:00:00 2001 From: Asaf Penso Date: Wed, 19 Jun 2019 09:46:24 +0000 Subject: [PATCH] net/mlx5: check memory allocation in flow creation 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: 84c406e74524 ("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 cd04c446b5..dc48252791 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2091,6 +2091,10 @@ flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list, 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; -- 2.20.1