From b6d538023dfddaf60acc10952d7f5ac06431ca17 Mon Sep 17 00:00:00 2001 From: Chaitanya Kulkarni Date: Thu, 23 Feb 2017 18:39:31 -0800 Subject: [PATCH] nvme-cli: id-ctrl: Fix memory leak for JSON. This patch fixes the following memory leak when id-ctrl command executed with JSON option:- ==7680== ==7680== HEAP SUMMARY: ==7680== in use at exit: 9,796 bytes in 338 blocks ==7680== total heap usage: 474 allocs, 136 frees, 24,729 bytes allocated ==7680== ==7680== LEAK SUMMARY: ==7680== definitely lost: 24 bytes in 1 blocks ==7680== indirectly lost: 9,772 bytes in 337 blocks ==7680== possibly lost: 0 bytes in 0 blocks ==7680== still reachable: 0 bytes in 0 blocks ==7680== suppressed: 0 bytes in 0 blocks Fix:- ==7971== ==7971== HEAP SUMMARY: ==7971== in use at exit: 0 bytes in 0 blocks ==7971== total heap usage: 474 allocs, 474 frees, 24,729 bytes allocated ==7971== Signed-off-by: Chaitanya Kulkarni --- nvme-print.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nvme-print.c b/nvme-print.c index 2467d27..bcc67ff 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1354,6 +1354,7 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode) json_print_object(root, NULL); printf("\n"); + json_free_object(root); } void json_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname) -- 2.49.0