[net] net: dsa: microchip: Don't try to read stats for unused ports
diff mbox series

Message ID 1560371612-31848-1-git-send-email-hancock@sedsystems.ca
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net] net: dsa: microchip: Don't try to read stats for unused ports
Related show

Commit Message

Robert Hancock June 12, 2019, 8:33 p.m. UTC
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>
---
 drivers/net/dsa/microchip/ksz_common.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Vivien Didelot June 12, 2019, 8:40 p.m. UTC | #1
On Wed, 12 Jun 2019 14:33:32 -0600, Robert Hancock <hancock@sedsystems.ca> wrote:
> 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>
Andrew Lunn June 12, 2019, 9:08 p.m. UTC | #2
On Wed, Jun 12, 2019 at 02:33:32PM -0600, Robert Hancock wrote:
> 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: Andrew Lunn <andrew@lunn.ch>

    Andrew
Florian Fainelli June 12, 2019, 9:41 p.m. UTC | #3
On 6/12/19 1:33 PM, Robert Hancock wrote:
> 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: Florian Fainelli <f.fainelli@gmail.com>
David Miller June 15, 2019, 2:10 a.m. UTC | #4
From: Robert Hancock <hancock@sedsystems.ca>
Date: Wed, 12 Jun 2019 14:33:32 -0600

> 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>

Applied and queued up for -stable.

Patch
diff mbox series

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 39dace8..f46086f 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -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);