net/mlx5_en: Add missing check for memory allocation failure
authorAmir Vadai <amirv@mellanox.com>
Thu, 4 Jun 2015 16:30:36 +0000 (19:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jun 2015 23:41:00 +0000 (16:41 -0700)
The patch afb736e9330a: "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: afb736e9330a ("net/mlx5: Ethernet resource handling files")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c

index 6feebda4b3e47d95dadc8e2d588db2259bcd2f7b..120db80c47aac425bf3c9d2eaac8b6ccd4cd674b 100644 (file)
@@ -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;