diff mbox

[net-next,01/17] net: dsa: slave: chip data is optional, don't dereference NULL

Message ID 1464972256-10408-2-git-send-email-andrew@lunn.ch
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Andrew Lunn June 3, 2016, 4:44 p.m. UTC
The new binding does not make use of dsa_chip_data, a.k.a cd.  When
retrieving the size of the EEPROM attached to a switch, don't assume
there is a cd attached to the switch structure.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 net/dsa/slave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Fainelli June 3, 2016, 5:16 p.m. UTC | #1
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> The new binding does not make use of dsa_chip_data, a.k.a cd.  When
> retrieving the size of the EEPROM attached to a switch, don't assume
> there is a cd attached to the switch structure.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Vivien Didelot June 3, 2016, 6:09 p.m. UTC | #2
Andrew Lunn <andrew@lunn.ch> writes:

> The new binding does not make use of dsa_chip_data, a.k.a cd.  When
> retrieving the size of the EEPROM attached to a switch, don't assume
> there is a cd attached to the switch structure.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
diff mbox

Patch

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 152436cdab30..135a91706755 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -615,7 +615,7 @@  static int dsa_slave_get_eeprom_len(struct net_device *dev)
 	struct dsa_slave_priv *p = netdev_priv(dev);
 	struct dsa_switch *ds = p->parent;
 
-	if (ds->cd->eeprom_len)
+	if (ds->cd && ds->cd->eeprom_len)
 		return ds->cd->eeprom_len;
 
 	if (ds->drv->get_eeprom_len)