aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/cache.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2019-02-06 22:41:49 -0700
committerJason Gunthorpe <jgg@mellanox.com>2019-02-08 16:56:45 -0700
commitd45f89d59bcd42d6b8575d0af69d7a3a98e73bb6 (patch)
tree7e2eab55760501c53c2ac750bb65e74cdd0a6026 /drivers/infiniband/core/cache.c
parentRDMA/device: Ensure that security memory is always freed (diff)
downloadlinux-dev-d45f89d59bcd42d6b8575d0af69d7a3a98e73bb6.tar.xz
linux-dev-d45f89d59bcd42d6b8575d0af69d7a3a98e73bb6.zip
RDMA/device: Call ib_cache_release_one() only from ib_device_release()
Instead of complicated logic about when this memory is freed, always free it during device release(). All the cache pointers start out as NULL, so it is safe to call this before the cache is initialized. This makes for a simpler error unwind flow, and a simpler understanding of the lifetime of the memory allocations inside the struct ib_device. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/cache.c')
-rw-r--r--drivers/infiniband/core/cache.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 7b04590f307f..2338d0b3a0ca 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1460,6 +1460,9 @@ void ib_cache_release_one(struct ib_device *device)
{
int p;
+ if (!device->cache.ports)
+ return;
+
/*
* The release function frees all the cache elements.
* This function should be called as part of freeing