Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx4_core: Fix access to uninitialized index

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>

authored by

Tariq Toukan and committed by
David S. Miller
2bb07e15 2ffd7e03

+2 -2
+2 -2
drivers/net/ethernet/mellanox/mlx4/mcg.c
··· 1102 1102 struct mlx4_cmd_mailbox *mailbox; 1103 1103 struct mlx4_mgm *mgm; 1104 1104 u32 members_count; 1105 - int index, prev; 1105 + int index = -1, prev; 1106 1106 int link = 0; 1107 1107 int i; 1108 1108 int err; ··· 1181 1181 goto out; 1182 1182 1183 1183 out: 1184 - if (prot == MLX4_PROT_ETH) { 1184 + if (prot == MLX4_PROT_ETH && index != -1) { 1185 1185 /* manage the steering entry for promisc mode */ 1186 1186 if (new_entry) 1187 1187 err = new_steering_entry(dev, port, steer,