From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 19 Oct 2014 14:41:47 +0000 (+0200)
Subject: Net: DSA: Fix checking for get_phy_flags function
X-Git-Tag: firefly_0821_release~176^2~3001^2
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=228b16cb13dfa2f77354a9b144a07e86e2dda01c;p=firefly-linux-kernel-4.4.55.git

Net: DSA: Fix checking for get_phy_flags function

The check for the presence or not of the optional switch function
get_phy_flags() called the function, rather than checked to see if it
is a NULL pointer. This causes a derefernce of a NULL pointer on all
switch chips except the sf2, the only switch to implement this call.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Fixes: 6819563e646a ("net: dsa: allow switch drivers to specify phy_device::dev_flags")
Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a851e9f14118..6d1817449c36 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -599,7 +599,7 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 	netif_carrier_off(slave_dev);
 
 	if (p->phy != NULL) {
-		if (ds->drv->get_phy_flags(ds, port))
+		if (ds->drv->get_phy_flags)
 			p->phy->dev_flags |= ds->drv->get_phy_flags(ds, port);
 
 		phy_attach(slave_dev, dev_name(&p->phy->dev),