Commit e3593b56 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/device: Check that the rename is nop under the lock

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: d21943dd ("RDMA/core: Implement IB device rename function")
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
parent 21a428a0
...@@ -189,12 +189,14 @@ static struct ib_device *__ib_device_get_by_name(const char *name) ...@@ -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 ib_device_rename(struct ib_device *ibdev, const char *name)
{ {
int ret = 0; int ret;
if (!strcmp(name, dev_name(&ibdev->dev)))
return ret;
mutex_lock(&device_mutex); mutex_lock(&device_mutex);
if (!strcmp(name, dev_name(&ibdev->dev))) {
ret = 0;
goto out;
}
if (__ib_device_get_by_name(name)) { if (__ib_device_get_by_name(name)) {
ret = -EEXIST; ret = -EEXIST;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment