From: Bart Van Assche <bart.vanass...@sandisk.com>

[ Upstream commit 642c7cbcaf2ffc1e27f67eda3dc47347ac5aff37 ]

Since index values equal to or above 'range' can trigger memory
corruption, complain if index >= range.

Signed-off-by: Bart Van Assche <bart.vanass...@sandisk.com>
Reviewed-by: Andrew Boyer <andrew.bo...@dell.com>
Cc: Moni Shoua <mo...@mellanox.com>
Signed-off-by: Doug Ledford <dledf...@redhat.com>
Signed-off-by: Sasha Levin <alexander.le...@verizon.com>
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c 
b/drivers/infiniband/sw/rxe/rxe_pool.c
index 6bac0717c540..ee26a1b1b4ed 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -274,6 +274,7 @@ static u32 alloc_index(struct rxe_pool *pool)
        if (index >= range)
                index = find_first_zero_bit(pool->table, range);
 
+       WARN_ON_ONCE(index >= range);
        set_bit(index, pool->table);
        pool->last = index;
        return index + pool->min_index;
-- 
2.11.0

Reply via email to