diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 1e3ac9b56c89..214dd703b0cc 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -842,13 +842,16 @@ static int dsa_switch_add(struct dsa_switch *ds) static int dsa_switch_probe(struct dsa_switch *ds) { - struct dsa_chip_data *pdata = ds->dev->platform_data; - struct device_node *np = ds->dev->of_node; + struct dsa_chip_data *pdata; + struct device_node *np; int err; if (!ds->dev) return -ENODEV; + pdata = ds->dev->platform_data; + np = ds->dev->of_node; + if (!ds->num_ports) return -EINVAL;