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: [email protected]
Signed-off-by: Abdun Nihaal <[email protected]>
---
 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


Reply via email to