* [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res
@ 2021-04-26 14:06 Lv Yunlong
2021-04-27 4:51 ` Leon Romanovsky
2021-04-27 18:31 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Lv Yunlong @ 2021-04-26 14:06 UTC (permalink / raw)
To: selvin.xavier, devesh.sharma, somnath.kotur,
sriharsha.basavapatna, nareshkumar.pbs, dledford, jgg
Cc: linux-rdma, linux-kernel, Lv Yunlong
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 <lyl2019@mail.ustc.edu.cn>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res
2021-04-26 14:06 [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res Lv Yunlong
@ 2021-04-27 4:51 ` Leon Romanovsky
2021-04-27 5:36 ` Devesh Sharma
2021-04-27 18:31 ` Jason Gunthorpe
1 sibling, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-04-27 4:51 UTC (permalink / raw)
To: Lv Yunlong
Cc: selvin.xavier, devesh.sharma, somnath.kotur,
sriharsha.basavapatna, nareshkumar.pbs, dledford, jgg,
linux-rdma, linux-kernel
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 <lyl2019@mail.ustc.edu.cn>
> ---
> drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> 1 file changed, 1 insertion(+)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res
2021-04-27 4:51 ` Leon Romanovsky
@ 2021-04-27 5:36 ` Devesh Sharma
0 siblings, 0 replies; 4+ messages in thread
From: Devesh Sharma @ 2021-04-27 5:36 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Lv Yunlong, Selvin Xavier, Somnath Kotur, Sriharsha Basavapatna,
Naresh Kumar PBS, Doug Ledford, Jason Gunthorpe, linux-rdma,
LKML
[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]
On Tue, Apr 27, 2021 at 10:21 AM Leon Romanovsky <leon@kernel.org> 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 <lyl2019@mail.ustc.edu.cn>
> > ---
> > drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>
--
-Regards
Devesh
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4212 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res
2021-04-26 14:06 [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res Lv Yunlong
2021-04-27 4:51 ` Leon Romanovsky
@ 2021-04-27 18:31 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2021-04-27 18:31 UTC (permalink / raw)
To: Lv Yunlong
Cc: selvin.xavier, devesh.sharma, somnath.kotur,
sriharsha.basavapatna, nareshkumar.pbs, dledford, linux-rdma,
linux-kernel
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 <lyl2019@mail.ustc.edu.cn>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>
> ---
> drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 +
> 1 file changed, 1 insertion(+)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-27 18:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 14:06 [PATCH] RDMA/bnxt_re/qplib_res: Fix a double free in bnxt_qplib_alloc_res Lv Yunlong
2021-04-27 4:51 ` Leon Romanovsky
2021-04-27 5:36 ` Devesh Sharma
2021-04-27 18:31 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).