diff mbox series

[for-rc,2/4] IB/hfi1: Call xa_destroy before unloading the module

Message ID 1617025700-31865-3-git-send-email-dennis.dalessandro@cornelisnetworks.com (mailing list archive)
State Rejected
Delegated to: Jason Gunthorpe
Headers show
Series hfi fixes | expand

Commit Message

Dennis Dalessandro March 29, 2021, 1:48 p.m. UTC
From: Kaike Wan <kaike.wan@intel.com>

Call xa_destroy for hfi1_dev_table before unloading the module to avoid
a potential memory leak.

Fixes: 03b92789e5cf ("hfi1: Convert hfi1_unit_table to XArray")
Cc: <stable@vger.kernel.org>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Gunthorpe March 29, 2021, 2:11 p.m. UTC | #1
On Mon, Mar 29, 2021 at 09:48:18AM -0400, dennis.dalessandro@cornelisnetworks.com wrote:
> From: Kaike Wan <kaike.wan@intel.com>
> 
> Call xa_destroy for hfi1_dev_table before unloading the module to avoid
> a potential memory leak.

Do you hit the WARN_ON or not?

Is this all just mindless?

If the xarray is supposed to be empty because everything was erased
then you don't need it, the WARN_ON is correct. An empty xarray needs
no further destruction.

Jason
Dennis Dalessandro April 8, 2021, 1:30 p.m. UTC | #2
On 3/29/2021 10:11 AM, Jason Gunthorpe wrote:
> On Mon, Mar 29, 2021 at 09:48:18AM -0400, dennis.dalessandro@cornelisnetworks.com wrote:
>> From: Kaike Wan <kaike.wan@intel.com>
>>
>> Call xa_destroy for hfi1_dev_table before unloading the module to avoid
>> a potential memory leak.
> 
> Do you hit the WARN_ON or not?
> 
> Is this all just mindless?
> 
> If the xarray is supposed to be empty because everything was erased
> then you don't need it, the WARN_ON is correct. An empty xarray needs
> no further destruction.

Looking at our internal bug that corresponds to this change, I don't see 
a WARN_ON that had been hit. I think we should just go ahead and drop 
these two patches for now and if we do hit the WARN_ON we will revisit.

-Denny
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index 93237bf..e4f8db4 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -1507,7 +1507,7 @@  static void __exit hfi1_mod_cleanup(void)
 	node_affinity_destroy_all();
 	hfi1_dbg_exit();
 
-	WARN_ON(!xa_empty(&hfi1_dev_table));
+	xa_destroy(&hfi1_dev_table);
 	dispose_firmware();	/* asymmetric with obtain_firmware() */
 	dev_cleanup();
 }