net/mlx4_core: Fix access to uninitialized index
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx4 / mcg.c
index 42d8de8..f2d0920 100644 (file)
@@ -39,8 +39,6 @@
 
 #include "mlx4.h"
 
-static const u8 zero_gid[16];  /* automatically initialized to 0 */
-
 int mlx4_get_mgm_entry_size(struct mlx4_dev *dev)
 {
        return 1 << dev->oper_log_mgm_entry_size;
@@ -1104,7 +1102,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
        struct mlx4_cmd_mailbox *mailbox;
        struct mlx4_mgm *mgm;
        u32 members_count;
-       int index, prev;
+       int index = -1, prev;
        int link = 0;
        int i;
        int err;
@@ -1183,7 +1181,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
                goto out;
 
 out:
-       if (prot == MLX4_PROT_ETH) {
+       if (prot == MLX4_PROT_ETH && index != -1) {
                /* manage the steering entry for promisc mode */
                if (new_entry)
                        err = new_steering_entry(dev, port, steer,