Commit 6db21d89 authored by Yuval Shaia's avatar Yuval Shaia Committed by Jason Gunthorpe

IB/rxe: Fix incorrect cache cleanup in error flow

Array iterator stays at the same slot, fix it.

Fixes: 8700e3e7 ("Soft RoCE driver")
Signed-off-by: default avatarYuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarZhu Yanjun <yanjun.zhu@oracle.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0c1c3880
...@@ -112,6 +112,18 @@ static inline struct kmem_cache *pool_cache(struct rxe_pool *pool) ...@@ -112,6 +112,18 @@ static inline struct kmem_cache *pool_cache(struct rxe_pool *pool)
return rxe_type_info[pool->type].cache; 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 rxe_cache_init(void)
{ {
int err; int err;
...@@ -136,24 +148,14 @@ int rxe_cache_init(void) ...@@ -136,24 +148,14 @@ int rxe_cache_init(void)
return 0; return 0;
err1: err1:
while (--i >= 0) { rxe_cache_clean(i);
kmem_cache_destroy(type->cache);
type->cache = NULL;
}
return err; return err;
} }
void rxe_cache_exit(void) void rxe_cache_exit(void)
{ {
int i; rxe_cache_clean(RXE_NUM_TYPES);
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;
}
} }
static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min) static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min)
......
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