]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/mlx5: Fix potential race between destroy and CQE poll
authorLeon Romanovsky <leonro@mellanox.com>
Sun, 30 Aug 2020 08:40:04 +0000 (11:40 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:07:52 +0000 (10:07 +0100)
[ Upstream commit 4b916ed9f9e85f705213ca8d69771d3c1cd6ee5a ]

The SRQ can be destroyed right before mlx5_cmd_get_srq is called.
In such case the latter will return NULL instead of expected SRQ.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Link: https://lore.kernel.org/r/20200830084010.102381-5-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/mlx5/cq.c

index 0c18cb6a2f148cec7ea4187a9c45363779dbfa26..3ca379513d0e65a97a1a8afb218822dbccb89523 100644 (file)
@@ -168,7 +168,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
 {
        enum rdma_link_layer ll = rdma_port_get_link_layer(qp->ibqp.device, 1);
        struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
-       struct mlx5_ib_srq *srq;
+       struct mlx5_ib_srq *srq = NULL;
        struct mlx5_ib_wq *wq;
        u16 wqe_ctr;
        u8  roce_packet_type;
@@ -180,7 +180,8 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
 
                if (qp->ibqp.xrcd) {
                        msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn));
-                       srq = to_mibsrq(msrq);
+                       if (msrq)
+                               srq = to_mibsrq(msrq);
                } else {
                        srq = to_msrq(qp->ibqp.srq);
                }