2020-06-12 20:11:13

by Aditya Pakki

[permalink] [raw]
Subject: [PATCH] net: ethernet: Fix potential memory leak caused in error handling

In ethoc_probe, a failure of mdiobus_register() does not release
the memory allocated by mdiobus_alloc. The patch fixes this issue.

Signed-off-by: Aditya Pakki <[email protected]>
---
drivers/net/ethernet/ethoc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index a817ca661c1f..2f6bab9f1d71 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1207,7 +1207,7 @@ static int ethoc_probe(struct platform_device *pdev)
ret = mdiobus_register(priv->mdio);
if (ret) {
dev_err(&netdev->dev, "failed to register MDIO bus\n");
- goto free2;
+ goto free_mdio;
}

ret = ethoc_mdio_probe(netdev);
@@ -1239,6 +1239,7 @@ static int ethoc_probe(struct platform_device *pdev)
netif_napi_del(&priv->napi);
error:
mdiobus_unregister(priv->mdio);
+free_mdio:
mdiobus_free(priv->mdio);
free2:
clk_disable_unprepare(priv->clk);
--
2.25.1


2020-06-12 20:49:10

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] net: ethernet: Fix potential memory leak caused in error handling

On Fri, Jun 12, 2020 at 03:06:54PM -0500, Aditya Pakki wrote:
> In ethoc_probe, a failure of mdiobus_register() does not release
> the memory allocated by mdiobus_alloc. The patch fixes this issue.

Hi Aditya

Please improve the Subject: line to indicate which driver you are
fixing.

A Fixes: tag would also be nice.

Andrew