Skip to contentSkip to conversation

pps: Fix IDR memory leak in module exit

PATCH In review Anders Roxell 2 participants 2 messages Jul 4, 2025 – Jul 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pps: Fix IDR memory leak in module exit

Add missing idr_destroy() call in pps_exit() to properly free the pps_idr radix tree nodes. Without this, module load/unload cycles leak 576-byte radix tree node allocations, detectable by kmemleak as:

unreferenced object (size 576):
backtrace:

    [<ffffffff81234567>] radix_tree_node_alloc+0xa0/0xf0
    [<ffffffff81234568>] idr_get_free+0x128/0x280

The pps_idr is initialized via DEFINE_IDR() at line 32 and used throughout the PPS subsystem for device ID management. The fix follows the documented pattern in lib/idr.c and matches the cleanup approach used by other drivers such as drivers/uio/uio.c.

This leak was discovered through comprehensive module testing with cumulative kmemleak detection across 10 load/unload iterations per module.

Fixes eae9d2ba0cfc ("LinuxPPS: core support")
---
 drivers/scsi/scsi_transport_iscsi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_transport_iscsi.c +1 -0
index c75a806496d6..adbedb58930d 100644
@@ -5024,6 +5024,7 @@ static void __exit iscsi_transport_exit(void)
 	class_unregister(&iscsi_endpoint_class);
 	class_unregister(&iscsi_iface_class);
 	class_unregister(&iscsi_transport_class);
+	idr_destroy(&iscsi_ep_idr);
 }
 
 module_init(iscsi_transport_init);
Signature · 1 line
2.47.2
#1 lore raw
Quoted 28 lines · Anders Roxell

Add missing idr_destroy() call in pps_exit() to properly free the pps_idr radix tree nodes. Without this, module load/unload cycles leak 576-byte radix tree node allocations, detectable by kmemleak as:

unreferenced object (size 576):

   backtrace:
     [<ffffffff81234567>] radix_tree_node_alloc+0xa0/0xf0
     [<ffffffff81234568>] idr_get_free+0x128/0x280

The pps_idr is initialized via DEFINE_IDR() at line 32 and used throughout the PPS subsystem for device ID management. The fix follows the documented pattern in lib/idr.c and matches the cleanup approach used by other drivers such as drivers/uio/uio.c.

This leak was discovered through comprehensive module testing with cumulative kmemleak detection across 10 load/unload iterations per module.

Fixes eae9d2ba0cfc ("LinuxPPS: core support")
---
  drivers/scsi/scsi_transport_iscsi.c | 1 +
  1 file changed, 1 insertion(+)
drivers/scsi/scsi_transport_iscsi.c +0 -0
index c75a806496d6..adbedb58930d 100644

drivers/scsi/scsi_transport_iscsi.c static void __exit iscsi_transport_exit(void) · line 5030

Quoted 7 lines
drivers/scsi/scsi_transport_iscsi.c +1 -0
@@ -5024,6 +5024,7 @@ static void __exit iscsi_transport_exit(void)
  	class_unregister(&iscsi_endpoint_class);
  	class_unregister(&iscsi_iface_class);
  	class_unregister(&iscsi_transport_class);
+	idr_destroy(&iscsi_ep_idr);
  }
 
  module_init(iscsi_transport_init);

Errm.
The description doesn't match the patch.
Care to fix it up?

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich