Skip to content

Commit

Permalink
net: dsa: bcm_sf2: put device node before return
Browse files Browse the repository at this point in the history
Put the device node dn before return error code on failure path.

Fixes: 461cd1b ("net: dsa: bcm_sf2: Register our slave MDIO bus")
Signed-off-by: Pan Bian <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
SinkFinder authored and kuba-moo committed Jan 23, 2021
1 parent 853c56b commit cf3c466
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/dsa/bcm_sf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,19 @@ static int bcm_sf2_mdio_register(struct dsa_switch *ds)
/* Find our integrated MDIO bus node */
dn = of_find_compatible_node(NULL, NULL, "brcm,unimac-mdio");
priv->master_mii_bus = of_mdio_find_bus(dn);
if (!priv->master_mii_bus)
if (!priv->master_mii_bus) {
of_node_put(dn);
return -EPROBE_DEFER;
}

get_device(&priv->master_mii_bus->dev);
priv->master_mii_dn = dn;

priv->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
if (!priv->slave_mii_bus)
if (!priv->slave_mii_bus) {
of_node_put(dn);
return -ENOMEM;
}

priv->slave_mii_bus->priv = priv;
priv->slave_mii_bus->name = "sf2 slave mii";
Expand Down

0 comments on commit cf3c466

Please sign in to comment.