net: emaclite: Add error handling for of_address_to_resource()
commit7a6bc33ab5
upstream. check the return value of of_address_to_resource() and also add missing of_node_put() for np and npp nodes. Fixes:e0a3bc6544
("net: emaclite: Support multiple phys connected to one MDIO bus") Addresses-Coverity: Event check_return value. Signed-off-by: Shravya Kumbham <shravya.kumbham@xilinx.com> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8010fdba29
commit
da07b2e273
@ -822,10 +822,10 @@ static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,
|
|||||||
static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
||||||
{
|
{
|
||||||
struct mii_bus *bus;
|
struct mii_bus *bus;
|
||||||
int rc;
|
|
||||||
struct resource res;
|
struct resource res;
|
||||||
struct device_node *np = of_get_parent(lp->phy_node);
|
struct device_node *np = of_get_parent(lp->phy_node);
|
||||||
struct device_node *npp;
|
struct device_node *npp;
|
||||||
|
int rc, ret;
|
||||||
|
|
||||||
/* Don't register the MDIO bus if the phy_node or its parent node
|
/* Don't register the MDIO bus if the phy_node or its parent node
|
||||||
* can't be found.
|
* can't be found.
|
||||||
@ -835,8 +835,14 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
npp = of_get_parent(np);
|
npp = of_get_parent(np);
|
||||||
|
ret = of_address_to_resource(npp, 0, &res);
|
||||||
of_address_to_resource(npp, 0, &res);
|
of_node_put(npp);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "%s resource error!\n",
|
||||||
|
dev->of_node->full_name);
|
||||||
|
of_node_put(np);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
if (lp->ndev->mem_start != res.start) {
|
if (lp->ndev->mem_start != res.start) {
|
||||||
struct phy_device *phydev;
|
struct phy_device *phydev;
|
||||||
phydev = of_phy_find_device(lp->phy_node);
|
phydev = of_phy_find_device(lp->phy_node);
|
||||||
@ -845,6 +851,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
|||||||
"MDIO of the phy is not registered yet\n");
|
"MDIO of the phy is not registered yet\n");
|
||||||
else
|
else
|
||||||
put_device(&phydev->mdio.dev);
|
put_device(&phydev->mdio.dev);
|
||||||
|
of_node_put(np);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,6 +864,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
|||||||
bus = mdiobus_alloc();
|
bus = mdiobus_alloc();
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
dev_err(dev, "Failed to allocate mdiobus\n");
|
dev_err(dev, "Failed to allocate mdiobus\n");
|
||||||
|
of_node_put(np);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,6 +877,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
|
|||||||
bus->parent = dev;
|
bus->parent = dev;
|
||||||
|
|
||||||
rc = of_mdiobus_register(bus, np);
|
rc = of_mdiobus_register(bus, np);
|
||||||
|
of_node_put(np);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(dev, "Failed to register mdio bus.\n");
|
dev_err(dev, "Failed to register mdio bus.\n");
|
||||||
goto err_register;
|
goto err_register;
|
||||||
|
Reference in New Issue
Block a user