Skip to content

Commit

Permalink
net: dsa: microchip: set the correct number of ports
Browse files Browse the repository at this point in the history
The number of ports is incorrectly set to the maximum available for a DSA
switch. Even if the extra ports are not used, this causes some functions
to be called later, like port_disable() and port_stp_state_set(). If the
driver doesn't check the port index, it will end up modifying unknown
registers.

Fixes: b987e98 ("dsa: add DSA switch driver for Microchip KSZ9477")
Signed-off-by: Codrin Ciubotariu <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
codrin989 authored and davem330 committed Jul 2, 2020
1 parent 1ca0faf commit af199a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/dsa/microchip/ksz8795.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,9 @@ static int ksz8795_switch_init(struct ksz_device *dev)
return -ENOMEM;
}

/* set the real number of ports */
dev->ds->num_ports = dev->port_cnt;

return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/net/dsa/microchip/ksz9477.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,9 @@ static int ksz9477_switch_init(struct ksz_device *dev)
return -ENOMEM;
}

/* set the real number of ports */
dev->ds->num_ports = dev->port_cnt;

return 0;
}

Expand Down

0 comments on commit af199a1

Please sign in to comment.