Skip to content

Commit

Permalink
net/mlx5: check memory allocation in flow creation
Browse files Browse the repository at this point in the history
[ upstream commit 3f22e31 ]

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: 84c406e ("net/mlx5: add flow translate function")

Signed-off-by: Asaf Penso <asafp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
  • Loading branch information
asafpenso authored and kevintraynor committed Aug 26, 2019
1 parent 922f0d1 commit 6b4c2b9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/mlx5/mlx5_flow.c
Expand Up @@ -2069,6 +2069,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);
assert(flow->drv_type > MLX5_FLOW_TYPE_MIN &&
flow->drv_type < MLX5_FLOW_TYPE_MAX);
Expand Down

0 comments on commit 6b4c2b9

Please sign in to comment.