diff options
author | Jason Gunthorpe | 2019-02-07 06:41:47 +0100 |
---|---|---|
committer | Jason Gunthorpe | 2019-02-09 00:56:45 +0100 |
commit | e3593b568a68b0e1a434b80fd6eaebfb655e839d (patch) | |
tree | b2b2e43346a0e34c89f532399db62d265e8ad4b5 /drivers/infiniband/core | |
parent | RDMA: Handle PD allocations by IB/core (diff) | |
download | kernel-qcow2-linux-e3593b568a68b0e1a434b80fd6eaebfb655e839d.tar.gz kernel-qcow2-linux-e3593b568a68b0e1a434b80fd6eaebfb655e839d.tar.xz kernel-qcow2-linux-e3593b568a68b0e1a434b80fd6eaebfb655e839d.zip |
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: d21943dd19b5 ("RDMA/core: Implement IB device rename function")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r-- | drivers/infiniband/core/device.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 57e1e177921e..60083bde3e39 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -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; |