net/mlx5_core: Fix race on driver load

When events arrive at driver load, the event handler gets called even before
the spinlock and list are initialized. Fix this by moving the initialization
before EQs creation.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eli Cohen 2014-11-06 12:51:22 +02:00 committed by David S. Miller
parent a158906dd7
commit 364d1798ef
1 changed files with 2 additions and 2 deletions

View File

@ -864,14 +864,14 @@ static int init_one(struct pci_dev *pdev,
dev->profile = &profile[prof_sel]; dev->profile = &profile[prof_sel];
dev->event = mlx5_core_event; dev->event = mlx5_core_event;
INIT_LIST_HEAD(&priv->ctx_list);
spin_lock_init(&priv->ctx_lock);
err = mlx5_dev_init(dev, pdev); err = mlx5_dev_init(dev, pdev);
if (err) { if (err) {
dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err); dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err);
goto out; goto out;
} }
INIT_LIST_HEAD(&priv->ctx_list);
spin_lock_init(&priv->ctx_lock);
err = mlx5_register_device(dev); err = mlx5_register_device(dev);
if (err) { if (err) {
dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err); dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err);