net: altera: Fix refcount leak in altera_tse_mdio_create
[ Upstream commit 11ec18b1d8d92b9df307d31950dcba0b3dd7283c ]
Every iteration of for_each_child_of_node() decrements
the reference count of the previous node.
When break from a for_each_child_of_node() loop,
we need to explicitly call of_node_put() on the child node when
not need anymore.
Add missing of_node_put() to avoid refcount leak.
Fixes: bbd2190ce9
("Altera TSE: Add main and header file for Altera Ethernet Driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220607041144.7553-1-linmq006@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
fbeb8dfa8b
commit
96bf5ed057
@@ -163,7 +163,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
|
|||||||
mdio = mdiobus_alloc();
|
mdio = mdiobus_alloc();
|
||||||
if (mdio == NULL) {
|
if (mdio == NULL) {
|
||||||
netdev_err(dev, "Error allocating MDIO bus\n");
|
netdev_err(dev, "Error allocating MDIO bus\n");
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto put_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdio->name = ALTERA_TSE_RESOURCE_NAME;
|
mdio->name = ALTERA_TSE_RESOURCE_NAME;
|
||||||
@@ -180,6 +181,7 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
|
|||||||
mdio->id);
|
mdio->id);
|
||||||
goto out_free_mdio;
|
goto out_free_mdio;
|
||||||
}
|
}
|
||||||
|
of_node_put(mdio_node);
|
||||||
|
|
||||||
if (netif_msg_drv(priv))
|
if (netif_msg_drv(priv))
|
||||||
netdev_info(dev, "MDIO bus %s: created\n", mdio->id);
|
netdev_info(dev, "MDIO bus %s: created\n", mdio->id);
|
||||||
@@ -189,6 +191,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
|
|||||||
out_free_mdio:
|
out_free_mdio:
|
||||||
mdiobus_free(mdio);
|
mdiobus_free(mdio);
|
||||||
mdio = NULL;
|
mdio = NULL;
|
||||||
|
put_node:
|
||||||
|
of_node_put(mdio_node);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user