Blob Blame History Raw
From: Parav Pandit <parav@mellanox.com>
Date: Tue, 28 Aug 2018 15:08:41 +0300
Subject: RDMA/core: No need to protect kfree with spin lock and semaphore
Patch-mainline: v4.20-rc1
Git-commit: 93688ddbe1da1ead030b210dadc5a8cfbff95849
References: bsc#1103992 FATE#326009

While unregistering a client, only context removal should be protected
with lock. There is no need to protect a freeing of such context which is
already removed from the list.

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>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/infiniband/core/device.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -700,9 +700,9 @@ void ib_unregister_client(struct ib_clie
 		down_write(&lists_rwsem);
 		spin_lock_irqsave(&device->client_data_lock, flags);
 		list_del(&found_context->list);
-		kfree(found_context);
 		spin_unlock_irqrestore(&device->client_data_lock, flags);
 		up_write(&lists_rwsem);
+		kfree(found_context);
 	}
 
 	mutex_unlock(&device_mutex);