Commit 4512acd0 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

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: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent f7b65d9b
...@@ -286,6 +286,7 @@ EXPORT_SYMBOL(ib_alloc_device); ...@@ -286,6 +286,7 @@ EXPORT_SYMBOL(ib_alloc_device);
*/ */
void ib_dealloc_device(struct ib_device *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 && WARN_ON(device->reg_state != IB_DEV_UNREGISTERED &&
device->reg_state != IB_DEV_UNINITIALIZED); device->reg_state != IB_DEV_UNINITIALIZED);
rdma_restrack_clean(&device->res); rdma_restrack_clean(&device->res);
...@@ -610,8 +611,11 @@ void ib_unregister_device(struct ib_device *device) ...@@ -610,8 +611,11 @@ void ib_unregister_device(struct ib_device *device)
down_write(&lists_rwsem); down_write(&lists_rwsem);
spin_lock_irqsave(&device->client_data_lock, flags); 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); kfree(context);
}
spin_unlock_irqrestore(&device->client_data_lock, flags); spin_unlock_irqrestore(&device->client_data_lock, flags);
up_write(&lists_rwsem); up_write(&lists_rwsem);
......
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