]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mlx4_core: Fix crash on uninitialized priv->cmd.slave_sem
authorRoland Dreier <roland@purestorage.com>
Wed, 26 Sep 2012 04:24:07 +0000 (21:24 -0700)
committerRoland Dreier <roland@purestorage.com>
Wed, 26 Sep 2012 04:35:14 +0000 (21:35 -0700)
commit7d1f317dd2741fa1aeaa03717929c0771db00432
tree4bbadd02ad0454dcfd5a1852fdff9036353c6286
parent0fd64ad30ed6bdc2133e377fb01652a433c89a3c
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>
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h