]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx4_core: Fix access to uninitialized index
authorTariq Toukan <tariqt@mellanox.com>
Sun, 15 May 2016 07:21:26 +0000 (10:21 +0300)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 22 Aug 2016 21:38:00 +0000 (22:38 +0100)
commit 2bb07e155bb3e0c722c806723f737cf8020961ef upstream.

Prevent using uninitialized or negative index when handling
steering entries.

Fixes: b12d93d63c32 ('mlx4: Add support for promiscuous mode in the new steering model.')
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ethernet/mellanox/mlx4/mcg.c

index 4c36def8e10f9b518a1ba8a3f05340eb63c4dc0a..d9afcffee737972d7d97edc8f9ea9eff955a0493 100644 (file)
@@ -953,7 +953,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;
@@ -1032,7 +1032,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)
                        new_steering_entry(dev, port, steer, index, qp->qpn);