cxl/test: Free the decoder registry when cxl_test_init() fails
Alison Schofield
maintainerPATCH 1/1 cxl/test: Free the decoder registry when cxl_test_init() fails
Decoder registry entries persist across mock device removal to support topology replay. Sashiko review found that if cxl_test_init() fails after decoders are enumerated, the entries leak because cxl_test_exit() is never called.
Free the registry entries and destroy the xarray during error unwind.
--- tools/testing/cxl/test/cxl.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
tools/testing/cxl/test/cxl.c +13 -11
@@ -2436,6 +2436,17 @@ static int cxl_topo_init(void)return cxl_type3_topo_init (); } +static void free_decoder_registry (void ) +{ +unsigned long index; +void *entry; + +xa_for_each (&decoder_registry, index, entry) { +xa_erase (&decoder_registry, index); +kfree (entry); + } +} +static __init int cxl_test_init (void ) {struct range mappable;
@@ -2525,20 +2536,11 @@ static __init int cxl_test_init(void)gen_pool_destroy (cxl_mock_pool); err_gen_pool_create:unregister_cxl_mock_ops (&cxl_mock_ops); +free_decoder_registry (); +xa_destroy (&decoder_registry);return rc; } -static void free_decoder_registry (void ) -{ -unsigned long index; -void *entry; - -xa_for_each (&decoder_registry, index, entry) { -xa_erase (&decoder_registry, index); -kfree (entry); - } -} - static __exit void cxl_test_exit(void) {hmem_test_exit ();
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.37.3
Quoted 9 lines · On Fri, 6 Nov 2026 14:22:37 -0800 Alison Schofield…
Decoder registry entries persist across mock device removal to support topology replay. Sashiko review found that if
cxl_test_init()fails after decoders are enumerated, the entries leak becausecxl_test_exit()is never called.Free the registry entries and destroy the xarray during error unwind.
Fixes f3b1d2260703 ("tools/testing/cxl: Enable replay of user regions as auto regions")Signed-off-by Alison Schofield <[email protected]>
Quoted 9 lines · Alison Schofield
Decoder registry entries persist across mock device removal to support topology replay. Sashiko review found that if
cxl_test_init()fails after decoders are enumerated, the entries leak becausecxl_test_exit()is never called.Free the registry entries and destroy the xarray during error unwind.
Fixes f3b1d2260703 ("tools/testing/cxl: Enable replay of user regions as auto regions")Signed-off-by Alison Schofield <[email protected]>
Applied to cxl/fixes:a5fb83dcf19a
Quoted 51 lines
--- tools/testing/cxl/test/cxl.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)tools/testing/cxl/test/cxl.c +13
-11@@ -2436,6 +2436,17 @@ static int cxl_topo_init(void)return cxl_type3_topo_init (); } +static void free_decoder_registry (void ) +{ +unsigned long index; +void *entry; + +xa_for_each (&decoder_registry, index, entry) { +xa_erase (&decoder_registry, index); +kfree (entry); + } +} +static __init int cxl_test_init (void ) {struct range mappable;@@ -2525,20 +2536,11 @@ static __init int cxl_test_init(void)gen_pool_destroy (cxl_mock_pool); err_gen_pool_create:unregister_cxl_mock_ops (&cxl_mock_ops); +free_decoder_registry (); +xa_destroy (&decoder_registry);return rc; } -static void free_decoder_registry (void ) -{ -unsigned long index; -void *entry; - -xa_for_each (&decoder_registry, index, entry) { -xa_erase (&decoder_registry, index); -kfree (entry); - } -} - static __exit void cxl_test_exit(void) {hmem_test_exit ();base-commit:
6628e7d4c6b25c8d18f1345e3a20d21829aae7e4