Skip to content

Commit

Permalink
net/mlx5_en: Add missing check for memory allocation failure
Browse files Browse the repository at this point in the history
The patch afb736e: "net/mlx5: Ethernet resource handling files"
from May 28, 2015, leads to the following static checker warning:

drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c:726 mlx5e_create_main_flow_table()
error: potential null dereference 'g'.  (kcalloc returns null)

Fixes: afb736e ("net/mlx5: Ethernet resource handling files")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Amir Vadai <[email protected]>
Signed-off-by: Or Gerlitz <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
amirv authored and davem330 committed Jun 4, 2015
1 parent 6a0d7a0 commit 5e24851
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ static int mlx5e_create_main_flow_table(struct mlx5e_priv *priv)
u8 *dmac;

g = kcalloc(9, sizeof(*g), GFP_KERNEL);
if (!g)
return -ENOMEM;

g[0].log_sz = 2;
g[0].match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
Expand Down

0 comments on commit 5e24851

Please sign in to comment.