diff options
author | Roland Dreier <roland@purestorage.com> | 2012-09-26 00:24:07 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2012-09-30 23:33:46 -0400 |
commit | f3d4c89ee4a8c993cc334a67f84a3fb724a1dd35 (patch) | |
tree | 5b003102f64cf1df23a43f738627e2f7cf1e21cc /drivers/net/ethernet/mellanox/mlx4/mlx4.h | |
parent | 84b1f1538fadd066cc9877c2276f3fefd8a79bc4 (diff) |
mlx4_core: Fix crash on uninitialized priv->cmd.slave_sem
On an SR-IOV master device, __mlx4_init_one() calls mlx4_init_hca()
before mlx4_multi_func_init(). However, for unlucky configurations,
mlx4_init_hca() might call mlx4_SENSE_PORT() (via mlx4_dev_cap()), and
that calls mlx4_cmd_imm() with MLX4_CMD_WRAPPED set.
However, on a multifunction device with MLX4_CMD_WRAPPED, __mlx4_cmd()
calls into mlx4_slave_cmd(), and that immediately tries to do
down(&priv->cmd.slave_sem);
but priv->cmd.slave_sem isn't initialized until mlx4_multi_func_init()
(which we haven't called yet). The next thing it tries to do is access
priv->mfunc.vhcr, but that hasn't been allocated yet.
Fix this by moving the initialization of slave_sem and vhcr up into
mlx4_cmd_init(). Also, since slave_sem is really just being used as a
mutex, convert it into a slave_cmd_mutex.
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/mlx4.h')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/mlx4.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 4b1fbd84a68f..71eed05426ec 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h | |||
@@ -513,9 +513,9 @@ struct mlx4_cmd { | |||
513 | struct pci_pool *pool; | 513 | struct pci_pool *pool; |
514 | void __iomem *hcr; | 514 | void __iomem *hcr; |
515 | struct mutex hcr_mutex; | 515 | struct mutex hcr_mutex; |
516 | struct mutex slave_cmd_mutex; | ||
516 | struct semaphore poll_sem; | 517 | struct semaphore poll_sem; |
517 | struct semaphore event_sem; | 518 | struct semaphore event_sem; |
518 | struct semaphore slave_sem; | ||
519 | int max_cmds; | 519 | int max_cmds; |
520 | spinlock_t context_lock; | 520 | spinlock_t context_lock; |
521 | int free_head; | 521 | int free_head; |