From: Chaitanya Kulkarni Date: Fri, 24 Feb 2017 02:39:35 +0000 (-0800) Subject: nvme-cli: smart-log: Fix memory leak for JSON. X-Git-Tag: v1.2~19 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=60b4957f2cec914c65339abf20f9c7ba36b33d83;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: smart-log: Fix memory leak for JSON. 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 --- diff --git a/nvme-print.c b/nvme-print.c index d93a97c9..5bcd3074 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -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)