net: dsa: microchip: set the correct number of ports
authorCodrin Ciubotariu <codrin.ciubotariu@microchip.com>
Thu, 2 Jul 2020 09:44:50 +0000 (12:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jul 2020 07:33:55 +0000 (09:33 +0200)
commit1ba3bb7159f41f337605ae32505a9f754933c4d4
treef03f3148480aa6b1f3291927bc9a7f4135dade27
parenta600d334c0382387fa177d94d3b7ea986b4aa83c
net: dsa: microchip: set the correct number of ports

[ Upstream commit af199a1a9cb02ec0194804bd46c174b6db262075 ]

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: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/microchip/ksz8795.c
drivers/net/dsa/microchip/ksz9477.c