]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: error-log: Fix memory leak for JSON.
authorChaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Fri, 24 Feb 2017 02:39:33 +0000 (18:39 -0800)
committerKeith Busch <keith.busch@intel.com>
Fri, 24 Feb 2017 15:18:45 +0000 (10:18 -0500)
This patch fixes the following memory leak when error-log command
executed with JSON option:-
==7690==
==7690== HEAP SUMMARY:
==7690==     in use at exit: 49,779 bytes in 1,708 blocks
==7690==   total heap usage: 2,242 allocs, 534 frees, 87,392 bytes allocated
==7690==
==7690== LEAK SUMMARY:
==7690==    definitely lost: 24 bytes in 1 blocks
==7690==    indirectly lost: 49,755 bytes in 1,707 blocks
==7690==      possibly lost: 0 bytes in 0 blocks
==7690==    still reachable: 0 bytes in 0 blocks
==7690==         suppressed: 0 bytes in 0 blocks

Fix:-
==8015==
==8015== HEAP SUMMARY:
==8015==     in use at exit: 0 bytes in 0 blocks
==8015==   total heap usage: 2,242 allocs, 2,242 frees, 87,392 bytes allocated
==8015==

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

index 5cdc3271dbcb501a0b8b04a6f84416681776d8f4..187b1644fd561af8d090b849d27e0c2879da103b 100644 (file)
@@ -1387,6 +1387,7 @@ void json_error_log(struct nvme_error_log_page *err_log, int entries, const char
 
        json_print_object(root, NULL);
        printf("\n");
+       json_free_object(root);
 }
 
 void json_nvme_resv_report(struct nvme_reservation_status *status)