diff mbox series

[rdma-rc] RDMA/qedr: Destroy XArray during release of resources

Message ID 3af204a14d3dadf4102cd55ef50f0d927bb97884.1666871711.git.leonro@nvidia.com (mailing list archive)
State Rejected
Headers show
Series [rdma-rc] RDMA/qedr: Destroy XArray during release of resources | expand

Commit Message

Leon Romanovsky Oct. 27, 2022, 12:01 p.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

Destroy XArray while releasing qedr resources.

Fixes: b6014f9e5f39 ("qedr: Convert qpidr to XArray")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
I'm sending it to -rc just because of dependency on
https://lore.kernel.org/linux-rdma/166687129991.306571.17052575958640789335.b4-ty@kernel.org/T/#m0e945baa7f2c87ede9f1711c992889602ede7875
qps is empty and nothing is really leaked here.
---
 drivers/infiniband/hw/qedr/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jason Gunthorpe Oct. 27, 2022, 12:05 p.m. UTC | #1
On Thu, Oct 27, 2022 at 03:01:16PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Destroy XArray while releasing qedr resources.
> 
> Fixes: b6014f9e5f39 ("qedr: Convert qpidr to XArray")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> I'm sending it to -rc just because of dependency on
> https://lore.kernel.org/linux-rdma/166687129991.306571.17052575958640789335.b4-ty@kernel.org/T/#m0e945baa7f2c87ede9f1711c992889602ede7875
> qps is empty and nothing is really leaked here.

if qps is known to be empty then this should be WARN_ON(!xa_empty()) -
destroying an xarray that holds allocated memory is never correct - it
will leak the elements

Also, this isn't "for-rc", so it should go to -next. With a dependency
like this the patch waits until linus merges the rc branch and then
-next merges linus's rcX tag to resolve the conflict.

Jason
Leon Romanovsky Oct. 27, 2022, 12:29 p.m. UTC | #2
On Thu, Oct 27, 2022 at 09:05:08AM -0300, Jason Gunthorpe wrote:
> On Thu, Oct 27, 2022 at 03:01:16PM +0300, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> > 
> > Destroy XArray while releasing qedr resources.
> > 
> > Fixes: b6014f9e5f39 ("qedr: Convert qpidr to XArray")
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> > I'm sending it to -rc just because of dependency on
> > https://lore.kernel.org/linux-rdma/166687129991.306571.17052575958640789335.b4-ty@kernel.org/T/#m0e945baa7f2c87ede9f1711c992889602ede7875
> > qps is empty and nothing is really leaked here.
> 
> if qps is known to be empty then this should be WARN_ON(!xa_empty()) -
> destroying an xarray that holds allocated memory is never correct - it
> will leak the elements
> 
> Also, this isn't "for-rc", so it should go to -next. With a dependency
> like this the patch waits until linus merges the rc branch and then
> -next merges linus's rcX tag to resolve the conflict.

Let's drop this patch. QPS is empty.

Thanks

> 
> Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c
index ba0c3e4c07d8..9f53afed2bd0 100644
--- a/drivers/infiniband/hw/qedr/main.c
+++ b/drivers/infiniband/hw/qedr/main.c
@@ -308,8 +308,10 @@  static void qedr_free_resources(struct qedr_dev *dev)
 {
 	int i;
 
-	if (IS_IWARP(dev))
+	if (IS_IWARP(dev)) {
 		destroy_workqueue(dev->iwarp_wq);
+		xa_destroy(&dev->qps);
+	}
 
 	for (i = 0; i < dev->num_cnq; i++) {
 		qedr_free_mem_sb(dev, &dev->sb_array[i], dev->sb_start + i);
@@ -407,8 +409,10 @@  static int qedr_alloc_resources(struct qedr_dev *dev)
 err2:
 	kfree(dev->sb_array);
 err_destroy_wq:
-	if (IS_IWARP(dev))
+	if (IS_IWARP(dev)) {
 		destroy_workqueue(dev->iwarp_wq);
+		xa_destroy(&dev->qps);
+	}
 err1:
 	kfree(dev->sgid_tbl);
 	return rc;