From: Chaitanya Kulkarni Date: Fri, 24 Feb 2017 02:39:34 +0000 (-0800) Subject: nvme-cli: resv-report: Fix memory leak. X-Git-Tag: v1.2~20 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fd255699b47b6f5f5fc8bc30ef4cf962d1e481f8;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: resv-report: Fix memory leak. 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 --- diff --git a/nvme-print.c b/nvme-print.c index 187b1644..d93a97c9 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -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 00a64669..4fe908fe 100644 --- 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; }