Skip to content

Commit 1b550da

Browse files
liuyonglong86gregkh
authored andcommitted
net: hns3: fix kernel crash when devlink reload during pf initialization
[ Upstream commit 93305b7 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b033da1 commit 1b550da

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
@@ -11614,6 +11614,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1161411614
if (ret)
1161511615
goto err_pci_uninit;
1161611616

11617+
devl_lock(hdev->devlink);
11618+
1161711619
/* Firmware command queue initialize */
1161811620
ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw);
1161911621
if (ret)
@@ -11793,6 +11795,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1179311795

1179411796
hclge_task_schedule(hdev, round_jiffies_relative(HZ));
1179511797

11798+
devl_unlock(hdev->devlink);
1179611799
return 0;
1179711800

1179811801
err_mdiobus_unreg:
@@ -11805,6 +11808,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
1180511808
err_cmd_uninit:
1180611809
hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw);
1180711810
err_devlink_uninit:
11811+
devl_unlock(hdev->devlink);
1180811812
hclge_devlink_uninit(hdev);
1180911813
err_pci_uninit:
1181011814
pcim_iounmap(pdev, hdev->hw.hw.io_base);

0 commit comments

Comments
 (0)