Skip to content

Commit

Permalink
net: lan966x: fix a couple off by one bugs
Browse files Browse the repository at this point in the history
The lan966x->ports[] array has lan966x->num_phys_ports elements.  These
are assigned in lan966x_probe().  That means the > comparison should be
changed to >=.

The first off by one check is harmless but the second one could lead to
an out of bounds access and a crash.

Fixes: 5ccd66e ("net: lan966x: add support for interrupts from analyzer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Apr 25, 2022
1 parent 4e2e65e commit 9810c58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,

lan966x_mac_process_raw_entry(&raw_entries[column],
mac, &vid, &dest_idx);
if (WARN_ON(dest_idx > lan966x->num_phys_ports))
if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
continue;

/* If the entry in SW is found, then there is nothing
Expand Down Expand Up @@ -393,7 +393,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,

lan966x_mac_process_raw_entry(&raw_entries[column],
mac, &vid, &dest_idx);
if (WARN_ON(dest_idx > lan966x->num_phys_ports))
if (WARN_ON(dest_idx >= lan966x->num_phys_ports))
continue;

mac_entry = lan966x_mac_alloc_entry(mac, vid, dest_idx);
Expand Down

0 comments on commit 9810c58

Please sign in to comment.