From: Bart Van Assche Date: Tue, 10 Jan 2017 19:15:48 +0000 (-0800) Subject: IB/rxe: Add a runtime check in alloc_index() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=642c7cbcaf2ffc1e27f67eda3dc47347ac5aff37;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git IB/rxe: Add a runtime check in alloc_index() Since index values equal to or above 'range' can trigger memory corruption, complain if index >= range. Signed-off-by: Bart Van Assche Reviewed-by: Andrew Boyer Cc: Moni Shoua Signed-off-by: Doug Ledford --- diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index 7d1e2862b928..75d11ee635ec 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -266,6 +266,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;