Commit 100e3345 authored by Dinghao Liu's avatar Dinghao Liu Committed by David S. Miller

net: hns: Fix memleak in hns_nic_dev_probe

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>
parent cb957121
...@@ -2282,8 +2282,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev) ...@@ -2282,8 +2282,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
priv->enet_ver = AE_VERSION_1; priv->enet_ver = AE_VERSION_1;
else if (acpi_dev_found(hns_enet_acpi_match[1].id)) else if (acpi_dev_found(hns_enet_acpi_match[1].id))
priv->enet_ver = AE_VERSION_2; priv->enet_ver = AE_VERSION_2;
else else {
return -ENXIO; ret = -ENXIO;
goto out_read_prop_fail;
}
/* try to find port-idx-in-ae first */ /* try to find port-idx-in-ae first */
ret = acpi_node_get_property_reference(dev->fwnode, ret = acpi_node_get_property_reference(dev->fwnode,
...@@ -2299,7 +2301,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev) ...@@ -2299,7 +2301,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
priv->fwnode = args.fwnode; priv->fwnode = args.fwnode;
} else { } else {
dev_err(dev, "cannot read cfg data from OF or acpi\n"); 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); ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment