From: Chaitanya Kulkarni Date: Fri, 24 Feb 2017 02:39:36 +0000 (-0800) Subject: nvme-cli: fw-log: Fix memory leak for JSON. X-Git-Tag: v1.2~18 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9d8d7467f2bd44e6b24439697878580f66c83a5d;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: fw-log: Fix memory leak for JSON. This patch fixes the following memory leak when fw-log command executed with JSON option:- ==7822== ==7822== HEAP SUMMARY: ==7822== in use at exit: 1,104 bytes in 38 blocks ==7822== total heap usage: 75 allocs, 37 frees, 5,103 bytes allocated ==7822== ==7822== LEAK SUMMARY: ==7822== definitely lost: 24 bytes in 1 blocks ==7822== indirectly lost: 1,080 bytes in 37 blocks ==7822== possibly lost: 0 bytes in 0 blocks ==7822== still reachable: 0 bytes in 0 blocks ==7822== suppressed: 0 bytes in 0 blocks Fix:- ==8436== ==8436== HEAP SUMMARY: ==8436== in use at exit: 0 bytes in 0 blocks ==8436== total heap usage: 75 allocs, 75 frees, 5,103 bytes allocated ==8436== Signed-off-by: Chaitanya Kulkarni --- diff --git a/nvme-print.c b/nvme-print.c index 5bcd3074..3d8b32c2 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1447,6 +1447,8 @@ void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname) json_print_object(root, NULL); printf("\n"); + json_free_object(fwsi); + json_free_object(root); } void json_add_smart_log(struct nvme_additional_smart_log *smart,