Skip to content

Commit

Permalink
mlx4_en: Fix out of bounds array access
Browse files Browse the repository at this point in the history
When searching for a free entry in either mlx4_register_vlan() or
mlx4_register_mac(), and there is no free entry, the loop terminates without
updating the local variable free thus causing out of array bounds access. Fix
this by adding a proper check outside the loop.

Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eli Cohen authored and David S. Miller committed Oct 25, 2010
1 parent b336369 commit 0926f91
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/mlx4/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index)
goto out;
}
}

if (free < 0) {
err = -ENOMEM;
goto out;
}

mlx4_dbg(dev, "Free MAC index is %d\n", free);

if (table->total == table->max) {
Expand Down Expand Up @@ -205,6 +211,11 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
}
}

if (free < 0) {
err = -ENOMEM;
goto out;
}

if (table->total == table->max) {
/* No free vlan entries */
err = -ENOSPC;
Expand Down

0 comments on commit 0926f91

Please sign in to comment.