Skip to content

Commit f2bc3af

Browse files
Tom Rixjgunthorpe
authored andcommitted
RDMA/ocrdma: Fix use after free in ocrdma_dealloc_ucontext_pd()
In ocrdma_dealloc_ucontext_pd() uctx->cntxt_pd is assigned to the variable pd and then after uctx->cntxt_pd is freed, the variable pd is passed to function _ocrdma_dealloc_pd() which dereferences pd directly or through its call to ocrdma_mbx_dealloc_pd(). Reorder the free using the variable pd. Cc: stable@vger.kernel.org Fixes: 21a428a ("RDMA: Handle PD allocations by IB/core") Link: https://lore.kernel.org/r/20201230024653.1516495-1-trix@redhat.com Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent a306aba commit f2bc3af

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ static void ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
434434
pr_err("%s(%d) Freeing in use pdid=0x%x.\n",
435435
__func__, dev->id, pd->id);
436436
}
437-
kfree(uctx->cntxt_pd);
438437
uctx->cntxt_pd = NULL;
439438
_ocrdma_dealloc_pd(dev, pd);
439+
kfree(pd);
440440
}
441441

442442
static struct ocrdma_pd *ocrdma_get_ucontext_pd(struct ocrdma_ucontext *uctx)

0 commit comments

Comments
 (0)