RDMA/core: Fix unsafe linked list traversal after failing to allocate CQ
authorXi Wang <wangxi11@huawei.com>
Tue, 1 Sep 2020 12:38:55 +0000 (20:38 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:55:28 +0000 (13:55 +0200)
commitc5452d1e9143d2d70dde5887c19d32c7e58e33a3
treeb7cab0c088b7044a907f6bacac76d134e150d463
parentf420254168c08191110fe86135aaecbfd8ef8b91
RDMA/core: Fix unsafe linked list traversal after failing to allocate CQ

[ Upstream commit 8aa64be019567c4f90d45c5082a4b6f22e182d00 ]

It's not safe to access the next CQ in list_for_each_entry() after
invoking ib_free_cq(), because the CQ has already been freed in current
iteration.  It should be replaced by list_for_each_entry_safe().

Fixes: c7ff819aefea ("RDMA/core: Introduce shared CQ pool API")
Link: https://lore.kernel.org/r/1598963935-32335-1-git-send-email-liweihang@huawei.com
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/core/cq.c