diff options
author | Parav Pandit <parav@mellanox.com> | 2018-08-28 15:08:43 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-09-06 13:45:38 -0600 |
commit | 4512acd0d34cea1bc0d9c69c1a60174016e121d7 (patch) | |
tree | eb6da91e7af209edd16b6feadee9d28288339b4d /drivers | |
parent | RDMA/core: Use simplified list_for_each (diff) | |
download | linux-dev-4512acd0d34cea1bc0d9c69c1a60174016e121d7.tar.xz linux-dev-4512acd0d34cea1bc0d9c69c1a60174016e121d7.zip |
RDMA/core: Remove context entries from list while unregistering device
While unregistering a device, remove the context elements from the list to
not have any stale entries. With that any errors/bugs can be checked when
device is freed.
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/device.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 559fbe6a97c2..81758477a882 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -286,6 +286,7 @@ EXPORT_SYMBOL(ib_alloc_device); */ void ib_dealloc_device(struct ib_device *device) { + WARN_ON(!list_empty(&device->client_data_list)); WARN_ON(device->reg_state != IB_DEV_UNREGISTERED && device->reg_state != IB_DEV_UNINITIALIZED); rdma_restrack_clean(&device->res); @@ -610,8 +611,11 @@ void ib_unregister_device(struct ib_device *device) down_write(&lists_rwsem); spin_lock_irqsave(&device->client_data_lock, flags); - list_for_each_entry_safe(context, tmp, &device->client_data_list, list) + list_for_each_entry_safe(context, tmp, &device->client_data_list, + list) { + list_del(&context->list); kfree(context); + } spin_unlock_irqrestore(&device->client_data_lock, flags); up_write(&lists_rwsem); |