diff mbox series

[v4] IB/rxe: Fix incorrect cache cleanup in error flow

Message ID 20181209135349.32475-1-yuval.shaia@oracle.com (mailing list archive)
State Accepted
Commit 6db21d8986e14e2e86573a3b055b05296188bd2c
Delegated to: Jason Gunthorpe
Headers show
Series [v4] IB/rxe: Fix incorrect cache cleanup in error flow | expand

Commit Message

Yuval Shaia Dec. 9, 2018, 1:53 p.m. UTC
Array iterator stays at the same slot, fix it.

Fixes: 8700e3e7c485 ("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>
---
v1 -> v2:
	* Add Fixes tag as suggested by Parav
	* Add Bart's r-b
v2 -> v3:
	* Remove blank line after "Fixes" tag as pointed out by Leon
v3 -> v4:
	* Accept comment from Yanjun
	* Add Yanjun's r-b
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Comments

Leon Romanovsky Dec. 9, 2018, 4:39 p.m. UTC | #1
On Sun, Dec 09, 2018 at 03:53:49PM +0200, Yuval Shaia wrote:
> Array iterator stays at the same slot, fix it.
>
> Fixes: 8700e3e7c485 ("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>
> ---

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe Dec. 11, 2018, 8:31 p.m. UTC | #2
On Sun, Dec 09, 2018 at 03:53:49PM +0200, Yuval Shaia wrote:
> Array iterator stays at the same slot, fix it.
> 
> Fixes: 8700e3e7c485 ("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>
> ---
> v1 -> v2:
> 	* Add Fixes tag as suggested by Parav
> 	* Add Bart's r-b
> v2 -> v3:
> 	* Remove blank line after "Fixes" tag as pointed out by Leon
> v3 -> v4:
> 	* Accept comment from Yanjun
> 	* Add Yanjun's r-b
> ---
>  drivers/infiniband/sw/rxe/rxe_pool.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)

Applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 36b53fb94a49..c24d003ce83f 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -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;
@@ -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)