Skip to content

Commit

Permalink
net: dsa: return early if there is no master
Browse files Browse the repository at this point in the history
It doesn't make sense to have DSA without a master port. Error out early
if there is no master port.

Fixes: fc054d5 ("net: Introduce DSA class for Ethernet switches")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
  • Loading branch information
mwalle authored and p-priyanka-jain committed Mar 5, 2021
1 parent 6ce33e2 commit a02dcbb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/dsa-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ static int dsa_port_probe(struct udevice *pdev)
if (!port_pdata->phy)
return -ENODEV;

master = dsa_get_master(dev);
if (!master)
return -ENODEV;

/*
* Inherit port's hwaddr from the DSA master, unless the port already
* has a unique MAC address specified in the environment.
Expand All @@ -288,10 +292,6 @@ static int dsa_port_probe(struct udevice *pdev)
if (!is_zero_ethaddr(env_enetaddr))
return 0;

master = dsa_get_master(dev);
if (!master)
return 0;

master_pdata = dev_get_plat(master);
eth_pdata = dev_get_plat(pdev);
memcpy(eth_pdata->enetaddr, master_pdata->enetaddr, ARP_HLEN);
Expand Down

0 comments on commit a02dcbb

Please sign in to comment.