mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
net: mv643xx_eth: fix an OF node reference leak
[ Upstream commit ad5c318086e2e23b577eca33559c5ebf89bc7eb9 ]
Current implementation of mv643xx_eth_shared_of_add_port() calls
of_parse_phandle(), but does not release the refcount on error. Call
of_node_put() in the error path and in mv643xx_eth_shared_of_remove().
This bug was found by an experimental verification tool that I am
developing.
Fixes: 76723bca28 ("net: mv643xx_eth: add DT parsing support")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://patch.msgid.link/20241221081448.3313163-1-joe@pf.is.s.u-tokyo.ac.jp
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
847c4daa21
commit
274cb294fa
@@ -2707,9 +2707,15 @@ static struct platform_device *port_platdev[3];
|
|||||||
|
|
||||||
static void mv643xx_eth_shared_of_remove(void)
|
static void mv643xx_eth_shared_of_remove(void)
|
||||||
{
|
{
|
||||||
|
struct mv643xx_eth_platform_data *pd;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < 3; n++) {
|
for (n = 0; n < 3; n++) {
|
||||||
|
if (!port_platdev[n])
|
||||||
|
continue;
|
||||||
|
pd = dev_get_platdata(&port_platdev[n]->dev);
|
||||||
|
if (pd)
|
||||||
|
of_node_put(pd->phy_node);
|
||||||
platform_device_del(port_platdev[n]);
|
platform_device_del(port_platdev[n]);
|
||||||
port_platdev[n] = NULL;
|
port_platdev[n] = NULL;
|
||||||
}
|
}
|
||||||
@@ -2770,8 +2776,10 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppdev = platform_device_alloc(MV643XX_ETH_NAME, dev_num);
|
ppdev = platform_device_alloc(MV643XX_ETH_NAME, dev_num);
|
||||||
if (!ppdev)
|
if (!ppdev) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto put_err;
|
||||||
|
}
|
||||||
ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
||||||
ppdev->dev.of_node = pnp;
|
ppdev->dev.of_node = pnp;
|
||||||
|
|
||||||
@@ -2793,6 +2801,8 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
|
|||||||
|
|
||||||
port_err:
|
port_err:
|
||||||
platform_device_put(ppdev);
|
platform_device_put(ppdev);
|
||||||
|
put_err:
|
||||||
|
of_node_put(ppd.phy_node);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user