]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: microchip: Don't try to read stats for unused ports
authorRobert Hancock <hancock@sedsystems.ca>
Wed, 12 Jun 2019 20:33:32 +0000 (14:33 -0600)
committerDavid S. Miller <davem@davemloft.net>
Sat, 15 Jun 2019 02:10:03 +0000 (19:10 -0700)
If some of the switch ports were not listed in the device tree, due to
being unused, the ksz_mib_read_work function ended up accessing a NULL
dp->slave pointer and causing an oops. Skip checking statistics for any
unused ports.

Fixes: 7c6ff470aa867f53 ("net: dsa: microchip: add MIB counter reading support")
Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz_common.c

index 39dace8e3512a4a49d5f5789e1b08477f92c030b..f46086fa906462e18913821153a7f1f936aa0799 100644 (file)
@@ -83,6 +83,9 @@ static void ksz_mib_read_work(struct work_struct *work)
        int i;
 
        for (i = 0; i < dev->mib_port_cnt; i++) {
+               if (dsa_is_unused_port(dev->ds, i))
+                       continue;
+
                p = &dev->ports[i];
                mib = &p->mib;
                mutex_lock(&mib->cnt_mutex);