Commit a6f262bd authored by Peiyang Wang's avatar Peiyang Wang Committed by chenyi
Browse files

net: hns3: release PTP resources if pf initialization failed

mainline inclusion
from mainline-v6.9-rc4
commit 950aa42399893a170d9b57eda0e4a3ff91fd8b70
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9QYBA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=950aa42399893a170d9b57eda0e4a3ff91fd8b70



----------------------------------------------------

During the PF initialization process, hclge_update_port_info may return an
error code for some reason. At this point,  the ptp initialization has been
completed. To void memory leaks, the resources that are applied by ptp
should be released. Therefore, when hclge_update_port_info returns an error
code, hclge_ptp_uninit is called to release the corresponding resources.

Fixes: eaf83ae5 ("net: hns3: add querying fec ability from firmware")
Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Reviewed-by: default avatarHariprasad Kelam <hkelam@marvell.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarchenyi <chenyi211@huawei.com>
parent ec110c84
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -12668,13 +12668,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)

	ret = hclge_update_port_info(hdev);
	if (ret)
		goto err_sysfs_unregister;
		goto err_ptp_uninit;

#if IS_ENABLED(CONFIG_UB_UDMA_HNS3)
	ret = hclge_set_fastpath_cmd(ae_dev, true);
	if (ret) {
		dev_err(&pdev->dev, "failed to init fastpath, ret = %d\n", ret);
		goto err_sysfs_unregister;
		goto err_ptp_uninit;
	}
#endif

@@ -12728,6 +12728,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)

err_sysfs_unregister:
	hclge_unregister_sysfs(hdev);
err_ptp_uninit:
	hclge_ptp_uninit(hdev);
err_mdiobus_unreg:
	if (hdev->hw.mac.phydev)
		mdiobus_unregister(hdev->hw.mac.mdio_bus);