RDMA/rxe: Fix resize_finish() in rxe_queue.c
authorBob Pearson <rpearsonhpe@gmail.com>
Thu, 25 Aug 2022 22:14:47 +0000 (17:14 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:35:16 +0000 (12:35 +0200)
commit041c79f6aefbafe6a516d83397ad6d3390915307
treebd8efa3029d2a1a7c4a054f04dc2327ce87f3377
parent959d4ee095e9816b722c76e3f127b0893d9444d6
RDMA/rxe: Fix resize_finish() in rxe_queue.c

[ Upstream commit fda5d0cf8aef12f0a4f714a96a4b2fce039a3e55 ]

Currently in resize_finish() in rxe_queue.c there is a loop which copies
the entries in the original queue into a newly allocated queue.  The
termination logic for this loop is incorrect. The call to
queue_next_index() updates cons but has no effect on whether the queue is
empty. So if the queue starts out empty nothing is copied but if it is not
then the loop will run forever. This patch changes the loop to compare the
value of cons to the original producer index.

Fixes: ae6e843fe08d0 ("RDMA/rxe: Add memory barriers to kernel queues")
Link: https://lore.kernel.org/r/20220825221446.6512-1-rpearsonhpe@gmail.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/sw/rxe/rxe_queue.c