]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: id-ns: Fix memory leak for JSON.
authorChaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Fri, 24 Feb 2017 02:39:32 +0000 (18:39 -0800)
committerKeith Busch <keith.busch@intel.com>
Fri, 24 Feb 2017 15:18:43 +0000 (10:18 -0500)
This patch fixes the following memory leak when id-ns command
executed with JSON option:-
==7642==
==7642== HEAP SUMMARY:
==7642==     in use at exit: 3,297 bytes in 120 blocks
==7642==   total heap usage: 182 allocs, 62 frees, 9,204 bytes allocated
==7642==
==7642== LEAK SUMMARY:
==7642==    definitely lost: 24 bytes in 1 blocks
==7642==    indirectly lost: 3,273 bytes in 119 blocks
==7642==      possibly lost: 0 bytes in 0 blocks
==7642==    still reachable: 0 bytes in 0 blocks
==7642==         suppressed: 0 bytes in 0 blocks
==7642== Rerun with --leak-check=full to see details of leaked memory
==7642==

Fix:-
==7949==
==7949== HEAP SUMMARY:
==7949==     in use at exit: 0 bytes in 0 blocks
==7949==   total heap usage: 182 allocs, 182 frees, 9,204 bytes allocated
==7949==

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
nvme-print.c

index bcc67ffd1b780f3b5d7f880d4f907058c5e67d81..5cdc3271dbcb501a0b8b04a6f84416681776d8f4 100644 (file)
@@ -1256,6 +1256,7 @@ void json_nvme_id_ns(struct nvme_id_ns *ns, unsigned int mode)
 
        json_print_object(root, NULL);
        printf("\n");
+       json_free_object(root);
 }
 
 void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode)