summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx4/srq.c
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2019-06-16 15:05:20 +0300
committerDoug Ledford <dledford@redhat.com>2019-06-20 15:17:59 -0400
commit836a0fbb3e76f704ad65ddfb57f00725245e509b (patch)
tree30d961b48c7029a952e6eeb5077d76ce0e4a5221 /drivers/infiniband/hw/mlx4/srq.c
parent89a6da3cb8f30ee0aeca924d84bef688f22f883e (diff)
downloadtalos-op-linux-836a0fbb3e76f704ad65ddfb57f00725245e509b.tar.gz
talos-op-linux-836a0fbb3e76f704ad65ddfb57f00725245e509b.zip
RDMA: Check umem pointer validity prior to release
Update ib_umem_release() to behave similarly to kfree() and allow submitting NULL pointer as safe input to this function. Fixes: a52c8e2469c3 ("RDMA: Clean destroy CQ in drivers do not return errors") Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx4/srq.c')
-rw-r--r--drivers/infiniband/hw/mlx4/srq.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
index c9f555e04c9f..848db7264cc9 100644
--- a/drivers/infiniband/hw/mlx4/srq.c
+++ b/drivers/infiniband/hw/mlx4/srq.c
@@ -204,10 +204,9 @@ err_mtt:
mlx4_mtt_cleanup(dev->dev, &srq->mtt);
err_buf:
- if (srq->umem)
- ib_umem_release(srq->umem);
- else
+ if (!srq->umem)
mlx4_buf_free(dev->dev, buf_size, &srq->buf);
+ ib_umem_release(srq->umem);
err_db:
if (!udata)
@@ -275,13 +274,13 @@ void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
struct mlx4_ib_ucontext,
ibucontext),
&msrq->db);
- ib_umem_release(msrq->umem);
} else {
kvfree(msrq->wrid);
mlx4_buf_free(dev->dev, msrq->msrq.max << msrq->msrq.wqe_shift,
&msrq->buf);
mlx4_db_free(dev->dev, &msrq->db);
}
+ ib_umem_release(msrq->umem);
}
void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index)
OpenPOWER on IntegriCloud