]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: hns3: release PTP resources if pf initialization failed
authorPeiyang Wang <wangpeiyang1@huawei.com>
Tue, 7 May 2024 13:42:21 +0000 (21:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 10:02:25 +0000 (12:02 +0200)
[ Upstream commit 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: eaf83ae59e18 ("net: hns3: add querying fec ability from firmware")
Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index b02b96bd93b7a04787cfb63bdbc0bc4c82f3cda2..7f2bb0e7088960a68de2c61f19a6f9c875b8b1a3 100644 (file)
@@ -11752,7 +11752,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
 
        ret = hclge_update_port_info(hdev);
        if (ret)
-               goto err_mdiobus_unreg;
+               goto err_ptp_uninit;
 
        INIT_KFIFO(hdev->mac_tnl_log);
 
@@ -11803,6 +11803,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
        devl_unlock(hdev->devlink);
        return 0;
 
+err_ptp_uninit:
+       hclge_ptp_uninit(hdev);
 err_mdiobus_unreg:
        if (hdev->hw.mac.phydev)
                mdiobus_unregister(hdev->hw.mac.mdio_bus);