[PATCH 1/2] nvdimm/btt: fix potential memory leak in discover_arenas()

From: Abdun Nihaal

Date: Tue May 19 2026 - 01:56:15 EST


Memory allocated in btt_freelist_init(), btt_rtt_init() and
btt_maplocks_init() which are called in discover_arenas() is not freed
in some error paths. Fix that by adding kfree() calls to error path.

Fixes: 5212e11fde4d ("nd_btt: atomic sector updates")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Abdun Nihaal <nihaal@xxxxxxxxxxxxxx>
---
drivers/nvdimm/btt.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index fdcb080a4314..e0b6a85a8124 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -919,6 +919,9 @@ static int discover_arenas(struct btt *btt)
return ret;

out:
+ kfree(arena->freelist);
+ kfree(arena->rtt);
+ kfree(arena->map_locks);
kfree(arena);
free_arenas(btt);
return ret;

--
2.43.0