]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: resv-report: Fix memory leak.
authorChaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Fri, 24 Feb 2017 02:39:34 +0000 (18:39 -0800)
committerKeith Busch <keith.busch@intel.com>
Fri, 24 Feb 2017 15:18:47 +0000 (10:18 -0500)
 This patch fixes the following memory leak for resv-report command:-
 ==7705==
 ==7705== HEAP SUMMARY:
 ==7705==     in use at exit: 4,096 bytes in 1 blocks
 ==7705==   total heap usage: 31 allocs, 30 frees, 7,941 bytes allocated
 ==7705==
 ==7705== LEAK SUMMARY:
 ==7705==    definitely lost: 4,096 bytes in 1 blocks
 ==7705==    indirectly lost: 0 bytes in 0 blocks
 ==7705==      possibly lost: 0 bytes in 0 blocks
 ==7705==    still reachable: 0 bytes in 0 blocks
 ==7705==         suppressed: 0 bytes in 0 blocks

 Fix:-
 ==8253==
 ==8253== HEAP SUMMARY:
 ==8253==     in use at exit: 0 bytes in 0 blocks
 ==8253==   total heap usage: 31 allocs, 31 frees, 7,941 bytes allocated
 ==8253==

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

index 187b1644fd561af8d090b849d27e0c2879da103b..d93a97c9b41cd5baab2d25b36565eb1ee06c5047 100644 (file)
@@ -1421,6 +1421,7 @@ void json_nvme_resv_report(struct nvme_reservation_status *status)
 
        json_print_object(root, NULL);
        printf("\n");
+       json_free_object(root);
 }
 
 void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname)
diff --git a/nvme.c b/nvme.c
index 00a64669e996e4eebc52f3e1669a1e50235abf7d..4fe908fe5d9d4a1bf21d40e2cbcbba79bffe973e 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2177,6 +2177,7 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
                        show_nvme_resv_report(status);
                }
        }
+       free(status);
        return err;
 }