]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: smart-log: Fix memory leak for JSON.
authorChaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Fri, 24 Feb 2017 02:39:35 +0000 (18:39 -0800)
committerKeith Busch <keith.busch@intel.com>
Fri, 24 Feb 2017 15:18:50 +0000 (10:18 -0500)
This patch fixes the following memory leak when smart-log command
executed with JSON option:-
==7725== HEAP SUMMARY:
==7725==     in use at exit: 1,661 bytes in 53 blocks
==7725==   total heap usage: 99 allocs, 46 frees, 6,559 bytes allocated
==7725==
==7725== LEAK SUMMARY:
==7725==    definitely lost: 24 bytes in 1 blocks
==7725==    indirectly lost: 1,637 bytes in 52 blocks
==7725==      possibly lost: 0 bytes in 0 blocks
==7725==    still reachable: 0 bytes in 0 blocks
==7725==         suppressed: 0 bytes in 0 blocks

Fix:-
==8322==
==8322== HEAP SUMMARY:
==8322==     in use at exit: 0 bytes in 0 blocks
==8322==   total heap usage: 99 allocs, 99 frees, 6,559 bytes allocated
==8322==

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

index d93a97c9b41cd5baab2d25b36565eb1ee06c5047..5bcd3074af12676b01da1f982bde24f396fdaa08 100644 (file)
@@ -1542,6 +1542,7 @@ void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char
 
        json_print_object(root, NULL);
        printf("\n");
+       json_free_object(root);
 }
 
 void show_registers_cap(struct nvme_bar_cap *cap)