Skip to content

Commit

Permalink
RDMA/device: Check that the rename is nop under the lock
Browse files Browse the repository at this point in the history
Since another rename could be running in parallel it is safer to check
that the name is not changing inside the lock, where we already know the
device name will not change.

Fixes: d21943d ("RDMA/core: Implement IB device rename function")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
  • Loading branch information
Jason Gunthorpe committed Feb 8, 2019
1 parent 21a428a commit e3593b5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/infiniband/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ static struct ib_device *__ib_device_get_by_name(const char *name)

int ib_device_rename(struct ib_device *ibdev, const char *name)
{
int ret = 0;

if (!strcmp(name, dev_name(&ibdev->dev)))
return ret;
int ret;

mutex_lock(&device_mutex);
if (!strcmp(name, dev_name(&ibdev->dev))) {
ret = 0;
goto out;
}

if (__ib_device_get_by_name(name)) {
ret = -EEXIST;
goto out;
Expand Down

0 comments on commit e3593b5

Please sign in to comment.