]> Git Repo - linux.git/commitdiff
RDMA/bnxt_re: Fix a double free in bnxt_qplib_alloc_res
authorLv Yunlong <[email protected]>
Mon, 26 Apr 2021 14:06:14 +0000 (07:06 -0700)
committerJason Gunthorpe <[email protected]>
Tue, 27 Apr 2021 18:22:29 +0000 (15:22 -0300)
In bnxt_qplib_alloc_res, it calls bnxt_qplib_alloc_dpi_tbl().  Inside
bnxt_qplib_alloc_dpi_tbl, dpit->dbr_bar_reg_iomem is freed via
pci_iounmap() in unmap_io error branch. After the callee returns err code,
bnxt_qplib_alloc_res calls
bnxt_qplib_free_res()->bnxt_qplib_free_dpi_tbl() in the fail branch. Then
dpit->dbr_bar_reg_iomem is freed in the second time by pci_iounmap().

My patch set dpit->dbr_bar_reg_iomem to NULL after it is freed by
pci_iounmap() in the first time, to avoid the double free.

Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Lv Yunlong <[email protected]>
Reviewed-by: Leon Romanovsky <[email protected]>
Acked-by: Devesh Sharma <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
drivers/infiniband/hw/bnxt_re/qplib_res.c

index fa7878336100ac778bf726e59f04ea7de732a04b..3ca47004b752789f32764f8b5678bd488f264540 100644 (file)
@@ -854,6 +854,7 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res     *res,
 
 unmap_io:
        pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
+       dpit->dbr_bar_reg_iomem = NULL;
        return -ENOMEM;
 }
 
This page took 0.064857 seconds and 4 git commands to generate.