diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2021-09-27 14:22:02 +0300 |
---|---|---|
committer | Ramon Fried <rfried.dev@gmail.com> | 2021-09-28 18:50:57 +0300 |
commit | c9131fc72b618ce24959447aa55f66f583c49e8a (patch) | |
tree | f07ce90b4de25d8a289373cc54ee75d594bf5080 | |
parent | 81386ed40590bf746849ce1a1d3a2edd869bad84 (diff) | |
download | u-boot-c9131fc72b618ce24959447aa55f66f583c49e8a.zip u-boot-c9131fc72b618ce24959447aa55f66f583c49e8a.tar.gz u-boot-c9131fc72b618ce24959447aa55f66f583c49e8a.tar.bz2 |
net: dsa: felix: check return code of mdio_alloc and mdio_register
These functions can return errors, it's best to catch them and trigger
the driver unwind code path.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
-rw-r--r-- | drivers/net/mscc_eswitch/felix_switch.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/net/mscc_eswitch/felix_switch.c b/drivers/net/mscc_eswitch/felix_switch.c index 711dd44..551fc2c 100644 --- a/drivers/net/mscc_eswitch/felix_switch.c +++ b/drivers/net/mscc_eswitch/felix_switch.c @@ -275,6 +275,7 @@ static void felix_init(struct udevice *dev) static int felix_probe(struct udevice *dev) { struct felix_priv *priv = dev_get_priv(dev); + int err; if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) { @@ -299,11 +300,18 @@ static int felix_probe(struct udevice *dev) struct mii_dev *mii_bus; mii_bus = mdio_alloc(); + if (!mii_bus) + return -ENOMEM; + mii_bus->read = felix_mdio_read; mii_bus->write = felix_mdio_write; mii_bus->priv = priv->imdio_base + FELIX_PM_IMDIO_BASE; strlcpy(mii_bus->name, dev->name, MDIO_NAME_LEN); - mdio_register(mii_bus); + err = mdio_register(mii_bus); + if (err) { + mdio_free(mii_bus); + return err; + } } dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY); |