From: Leon Romanovsky leonro@nvidia.com
mainline inclusion from mainline-master commit a1fcb106ae97cc34cc8101efafb89eaa837be009 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I46N6O CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
----------------------------------------------------------------------
The devlink pointer always exists after hclge_devlink_init() succeed. Remove that check together with NULL setting after release and ensure that devlink_register is last command prior to call to devlink_reload_enable().
Fixes: b741269b2759 ("net: hns3: add support for registering devlink for PF") Signed-off-by: Leon Romanovsky leonro@nvidia.com Signed-off-by: David S. Miller davem@davemloft.net Reviewed-by: Yongxin Li liyongxin1@huawei.com Signed-off-by: Junxin Chen chenjunxin1@huawei.com (fix conflicts: interface devlink_register adapt) Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c | 8 +------- .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c index 06d29945d4e1..65802ecf848f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -118,6 +118,7 @@ int hclge_devlink_init(struct hclge_dev *hdev)
priv = devlink_priv(devlink); priv->hdev = hdev; + hdev->devlink = devlink;
ret = devlink_register(devlink, &pdev->dev); if (ret) { @@ -126,8 +127,6 @@ int hclge_devlink_init(struct hclge_dev *hdev) goto out_reg_fail; }
- hdev->devlink = devlink; - devlink_reload_enable(devlink);
return 0; @@ -141,14 +140,9 @@ void hclge_devlink_uninit(struct hclge_dev *hdev) { struct devlink *devlink = hdev->devlink;
- if (!devlink) - return; - devlink_reload_disable(devlink);
devlink_unregister(devlink);
devlink_free(devlink); - - hdev->devlink = NULL; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c index 21a45279fd99..d209a17927e5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c @@ -119,6 +119,7 @@ int hclgevf_devlink_init(struct hclgevf_dev *hdev)
priv = devlink_priv(devlink); priv->hdev = hdev; + hdev->devlink = devlink;
ret = devlink_register(devlink, &pdev->dev); if (ret) { @@ -127,8 +128,6 @@ int hclgevf_devlink_init(struct hclgevf_dev *hdev) goto out_reg_fail; }
- hdev->devlink = devlink; - devlink_reload_enable(devlink);
return 0; @@ -142,14 +141,9 @@ void hclgevf_devlink_uninit(struct hclgevf_dev *hdev) { struct devlink *devlink = hdev->devlink;
- if (!devlink) - return; - devlink_reload_disable(devlink);
devlink_unregister(devlink);
devlink_free(devlink); - - hdev->devlink = NULL; }