Skip to content

Commit 93305b7

Browse files
liuyonglong86Paolo Abeni
authored andcommitted
net: hns3: fix kernel crash when devlink reload during pf initialization
The devlink reload process will access the hardware resources, but the register operation is done before the hardware is initialized. So, processing the devlink reload during initialization may lead to kernel crash. This patch fixes this by taking devl_lock during initialization. Fixes: b741269 ("net: hns3: add support for registering devlink for PF") Signed-off-by: Yonglong Liu <liuyonglong@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 47e39d2 commit 93305b7

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11626,6 +11626,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1162611626
if (ret)
1162711627
goto err_pci_uninit;
1162811628

11629+
devl_lock(hdev->devlink);
11630+
1162911631
/* Firmware command queue initialize */
1163011632
ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw);
1163111633
if (ret)
@@ -11805,6 +11807,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1180511807

1180611808
hclge_task_schedule(hdev, round_jiffies_relative(HZ));
1180711809

11810+
devl_unlock(hdev->devlink);
1180811811
return 0;
1180911812

1181011813
err_mdiobus_unreg:
@@ -11817,6 +11820,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1181711820
err_cmd_uninit:
1181811821
hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw);
1181911822
err_devlink_uninit:
11823+
devl_unlock(hdev->devlink);
1182011824
hclge_devlink_uninit(hdev);
1182111825
err_pci_uninit:
1182211826
pcim_iounmap(pdev, hdev->hw.hw.io_base);

0 commit comments

Comments
 (0)