net/mlx5: Fix race for multiple RoCE enable
authorDaniel Jurgens <danielj@mellanox.com>
Thu, 4 Jan 2018 15:25:31 +0000 (17:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Apr 2018 10:32:17 +0000 (12:32 +0200)
commit35a9ebd920aaaa6425436b6660e71ca831531da1
treeb12ae0a64b71c806404c40aaf7dbcb9076664384
parent46d19334ca40d73a57d0519b5d9b5762d7e7c491
net/mlx5: Fix race for multiple RoCE enable

[ Upstream commit 734dc065fc41f6143ff88225aa5d335cb1e0f6aa ]

There are two potential problems with the existing implementation.

1. Enable and disable can race after the atomic operations.
2. If a command fails the refcount is left in an inconsistent state.

Introduce a lock and perform error checking.

Fixes: a6f7d2aff623 ("net/mlx5: Add support for multiple RoCE enable")
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlx5/core/vport.c
include/linux/mlx5/driver.h