scsi: iscsi: Fix IDR memory leak in transport exit
PATCH 1/1 scsi: iscsi: Fix IDR memory leak in transport exit
Add missing idr_destroy() call in iscsi_transport_exit() to properly free the iscsi_ep_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/0x280The iscsi_ep_idr is initialized via DEFINE_IDR() at line 89 and used throughout the iSCSI transport layer for endpoint ID management with proper mutex protection via iscsi_ep_idr_mutex. The fix follows the documented pattern in lib/idr.c and matches the cleanup approach used by other drivers.
This leak was discovered through comprehensive module testing with cumulative kmemleak detection across 10 load/unload iterations per module.
--- drivers/pps/pps.c | 1 + 1 file changed, 1 insertion(+)
drivers/pps/pps.c +1 -0
@@ -456,6 +456,7 @@ static void __exit pps_exit(void) {class_destroy (pps_class);__unregister_chrdev (pps_major,0 ,PPS_MAX_SOURCES ,"pps" ); +idr_destroy (&pps_idr); }static int __init pps_init (void )
Signature · 1 line
2.47.2
Rodolfo Giometti
maintainerQuoted 9 lines · Anders Roxell
Add missing
idr_destroy()call iniscsi_transport_exit()to properly free theiscsi_ep_idrradix 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
Quoted 8 lines
The
iscsi_ep_idris initialized viaDEFINE_IDR()at line 89 and used throughout the iSCSI transport layer for endpoint ID management with proper mutex protection viaiscsi_ep_idr_mutex. The fix follows the documented pattern inlib/idr.cand matches the cleanup approach used by other drivers.This leak was discovered through comprehensive module testing with cumulative kmemleak detection across 10 load/unload iterations per module.
This test has been done on PPS sources too?
Quoted 1 line
Fixes 3c6ae371b8a1 ("scsi: iscsi: Release endpoint ID when its freed")
I think that the patch description should be linked to the code it applies to.
Maybe the patch is needed, but if you only modify the PPS code you should also provide a description of the problem within the PPS subsystem.
Ciao,
Rodolfo
Quoted 17 lines
Signed-off-by Anders Roxell <[email protected]>--- drivers/pps/pps.c | 1 + 1 file changed, 1 insertion(+)drivers/pps/pps.c +1
-0@@ -456,6 +456,7 @@ static void __exit pps_exit(void) {class_destroy (pps_class);__unregister_chrdev (pps_major,0 ,PPS_MAX_SOURCES ,"pps" ); +idr_destroy (&pps_idr); }static int __init pps_init (void )
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming