1
0
Fork 0

net: hns: Fix memleak in hns_nic_dev_probe

[ Upstream commit 100e3345c6 ]

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

Fixes: 63434888aa ("net: hns: net: hns: enet adds support of acpi")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5.4-rM2-2.2.x-imx-squashed
Dinghao Liu 2020-08-24 13:44:42 +08:00 committed by Greg Kroah-Hartman
parent 210b889fd8
commit a49c0aebf9
1 changed files with 6 additions and 3 deletions

View File

@ -2296,8 +2296,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,
@ -2313,7 +2315,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);