Skip to content

Commit

Permalink
RDMA/cache: Release GID table even if leak is detected
Browse files Browse the repository at this point in the history
When the table is released, we nullify pointer to GID table, it means
that in case GID entry leak is detected, we will leak table too.

Delete code that prevents table destruction.

Fixes: b150c38 ("IB/core: Introduce GID entry reference counts")
Link: https://lore.kernel.org/r/a62560af06ba82c88ef9194982bfa63d14768ff9.1716900410.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
  • Loading branch information
Leon Romanovsky authored and Jason Gunthorpe committed Jun 21, 2024
1 parent b7161db commit a92fbea
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/infiniband/core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,6 @@ static struct ib_gid_table *alloc_gid_table(int sz)
static void release_gid_table(struct ib_device *device,
struct ib_gid_table *table)
{
bool leak = false;
int i;

if (!table)
Expand All @@ -803,15 +802,12 @@ static void release_gid_table(struct ib_device *device,
for (i = 0; i < table->sz; i++) {
if (is_gid_entry_free(table->data_vec[i]))
continue;
if (kref_read(&table->data_vec[i]->kref) > 1) {
dev_err(&device->dev,
"GID entry ref leak for index %d ref=%u\n", i,
kref_read(&table->data_vec[i]->kref));
leak = true;
}

WARN_ONCE(true,
"GID entry ref leak for dev %s index %d ref=%u\n",
dev_name(&device->dev), i,
kref_read(&table->data_vec[i]->kref));
}
if (leak)
return;

mutex_destroy(&table->lock);
kfree(table->data_vec);
Expand Down

0 comments on commit a92fbea

Please sign in to comment.