Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe46ff0c authored by Dinghao Liu's avatar Dinghao Liu Committed by Greg Kroah-Hartman
Browse files

net: hns: Fix memleak in hns_nic_dev_probe



[ Upstream commit 100e3345c6e719d2291e1efd5de311cc24bb9c0b ]

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

Fixes: 63434888 ("net: hns: net: hns: enet adds support of acpi")
Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent f08569eb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1990,8 +1990,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,
@@ -2003,7 +2005,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
		priv->fwnode = acpi_fwnode_handle(args.adev);
	} 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);