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 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: 1ac5a40479752 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Lv Yunlong <[email protected]>
---
drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c
index fa7878336100..3ca47004b752 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_res.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c
@@ -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;
}
--
2.25.1
On Mon, Apr 26, 2021 at 07:06:14AM -0700, Lv Yunlong wrote:
> 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 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: 1ac5a40479752 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Lv Yunlong <[email protected]>
> ---
> drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> 1 file changed, 1 insertion(+)
>
Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>
On Tue, Apr 27, 2021 at 10:21 AM Leon Romanovsky <[email protected]> wrote:
>
> On Mon, Apr 26, 2021 at 07:06:14AM -0700, Lv Yunlong wrote:
> > 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 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: 1ac5a40479752 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> > Signed-off-by: Lv Yunlong <[email protected]>
> > ---
> > drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
>
> Thanks,
> Reviewed-by: Leon Romanovsky <[email protected]>
Acked-By: Devesh Sharma <[email protected]>
--
-Regards
Devesh
On Mon, Apr 26, 2021 at 07:06:14AM -0700, Lv Yunlong wrote:
> 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 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: 1ac5a40479752 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Lv Yunlong <[email protected]>
> Reviewed-by: Leon Romanovsky <[email protected]>
> Acked-By: Devesh Sharma <[email protected]>
> ---
> drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> 1 file changed, 1 insertion(+)
Applied to for-next, thanks
Jason