Skip to content

Commit

Permalink
IB/rxe: Fix incorrect cache cleanup in error flow
Browse files Browse the repository at this point in the history
Array iterator stays at the same slot, fix it.

Fixes: 8700e3e ("Soft RoCE driver")
Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Zhu Yanjun <yanjun.zhu@oracle.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Yuval Shaia authored and Jason Gunthorpe committed Dec 11, 2018
1 parent 0c1c388 commit 6db21d8
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions drivers/infiniband/sw/rxe/rxe_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ static inline struct kmem_cache *pool_cache(struct rxe_pool *pool)
return rxe_type_info[pool->type].cache;
}

static void rxe_cache_clean(size_t cnt)
{
int i;
struct rxe_type_info *type;

for (i = 0; i < cnt; i++) {
type = &rxe_type_info[i];
kmem_cache_destroy(type->cache);
type->cache = NULL;
}
}

int rxe_cache_init(void)
{
int err;
Expand All @@ -136,24 +148,14 @@ int rxe_cache_init(void)
return 0;

err1:
while (--i >= 0) {
kmem_cache_destroy(type->cache);
type->cache = NULL;
}
rxe_cache_clean(i);

return err;
}

void rxe_cache_exit(void)
{
int i;
struct rxe_type_info *type;

for (i = 0; i < RXE_NUM_TYPES; i++) {
type = &rxe_type_info[i];
kmem_cache_destroy(type->cache);
type->cache = NULL;
}
rxe_cache_clean(RXE_NUM_TYPES);
}

static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min)
Expand Down

0 comments on commit 6db21d8

Please sign in to comment.