From: Dinghao Liu <dinghao.liu@zju.edu.cn>
To: dinghao.liu@zju.edu.cn, kjlu@umn.edu
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
Arnd Bergmann <arnd@arndb.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] net: ethernet: Fix memleak in ethoc_probe
Date: Wed, 23 Dec 2020 19:06:12 +0800 [thread overview]
Message-ID: <20201223110615.31389-1-dinghao.liu@zju.edu.cn> (raw)
When mdiobus_register() fails, priv->mdio allocated
by mdiobus_alloc() has not been freed, which leads
to memleak.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
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 0981fe9652e5..3d9b0b161e24 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1211,7 +1211,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 free3;
}
ret = ethoc_mdio_probe(netdev);
@@ -1243,6 +1243,7 @@ static int ethoc_probe(struct platform_device *pdev)
netif_napi_del(&priv->napi);
error:
mdiobus_unregister(priv->mdio);
+free3:
mdiobus_free(priv->mdio);
free2:
clk_disable_unprepare(priv->clk);
--
2.17.1
next reply other threads:[~2020-12-23 11:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 11:06 Dinghao Liu [this message]
2020-12-23 15:33 ` [PATCH] net: ethernet: Fix memleak in ethoc_probe Andrew Lunn
2020-12-23 20:32 ` Jakub Kicinski
2020-12-23 21:00 ` Andrew Lunn
2020-12-23 21:11 ` Jakub Kicinski
2020-12-23 22:17 ` Florian Fainelli
2020-12-24 1:41 ` Jakub Kicinski
2020-12-24 18:06 ` Konstantin Ryabitsev
2020-12-24 21:57 ` Florian Fainelli
2020-12-28 20:23 ` Konstantin Ryabitsev
2020-12-28 21:05 ` Florian Fainelli
2020-12-28 21:14 ` Konstantin Ryabitsev
2020-12-30 21:36 ` Jakub Kicinski
2021-01-06 10:56 ` dinghao.liu
2021-01-06 16:44 ` Jakub Kicinski
2021-01-07 7:54 ` dinghao.liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201223110615.31389-1-dinghao.liu@zju.edu.cn \
--to=dinghao.liu@zju.edu.cn \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=jesse.brandeburg@intel.com \
--cc=kjlu@umn.edu \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).