All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: hns: Fix memleak in hns_nic_dev_probe
@ 2020-08-24  5:44 Dinghao Liu
  2020-08-24 12:54 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-08-24  5:44 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Yisen Zhuang, Salil Mehta, David S. Miller, Jakub Kicinski,
	Heiner Kallweit, Jason A. Donenfeld, Shannon Nelson,
	Michael S. Tsirkin, Yonglong Liu, Kejian Yan, netdev,
	linux-kernel

hns_nic_dev_probe allocates ndev, but not free it on
two error handling paths, which may lead to memleak.

Fixes: 63434888aaf1b ("net: hns: net: hns: enet adds support of acpi")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 23f278e46975..22522f8a5299 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -2282,8 +2282,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 			priv->enet_ver = AE_VERSION_1;
 		else if (acpi_dev_found(hns_enet_acpi_match[1].id))
 			priv->enet_ver = AE_VERSION_2;
-		else
-			return -ENXIO;
+		else {
+			ret = -ENXIO;
+			goto out_read_prop_fail;
+		}
 
 		/* try to find port-idx-in-ae first */
 		ret = acpi_node_get_property_reference(dev->fwnode,
@@ -2299,7 +2301,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 		priv->fwnode = args.fwnode;
 	} else {
 		dev_err(dev, "cannot read cfg data from OF or acpi\n");
-		return -ENXIO;
+		ret = -ENXIO;
+		goto out_read_prop_fail;
 	}
 
 	ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: hns: Fix memleak in hns_nic_dev_probe
  2020-08-24  5:44 [PATCH] net: hns: Fix memleak in hns_nic_dev_probe Dinghao Liu
@ 2020-08-24 12:54 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-24 12:54 UTC (permalink / raw)
  To: dinghao.liu
  Cc: kjlu, yisen.zhuang, salil.mehta, kuba, hkallweit1, Jason,
	snelson, mst, liuyonglong, yankejian, netdev, linux-kernel

From: Dinghao Liu <dinghao.liu@zju.edu.cn>
Date: Mon, 24 Aug 2020 13:44:42 +0800

> hns_nic_dev_probe allocates ndev, but not free it on
> two error handling paths, which may lead to memleak.
> 
> Fixes: 63434888aaf1b ("net: hns: net: hns: enet adds support of acpi")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-24 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24  5:44 [PATCH] net: hns: Fix memleak in hns_nic_dev_probe Dinghao Liu
2020-08-24 12:54 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.