From: Minwoo Im Date: Mon, 9 Apr 2018 17:27:22 +0000 (+0900) Subject: nvme-cli: fix leak in endurance_log command X-Git-Tag: v1.6~56^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f9fa2b9001f1abfb0d2fcb96d3aa8c3de83a7313;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: fix leak in endurance_log command Fix file descriptor leak in endurance_log subcommand. Signed-off-by: Minwoo Im --- diff --git a/nvme.c b/nvme.c index 0d42863b..cebfd3f6 100644 --- a/nvme.c +++ b/nvme.c @@ -370,8 +370,10 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct return fd; fmt = validate_output_format(cfg.output_format); - if (fmt < 0) - return fmt; + if (fmt < 0) { + err = fmt; + goto close_fd; + } err = nvme_endurance_log(fd, cfg.group_id, &endurance_log); if (!err) { @@ -387,6 +389,7 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct else perror("endurance log"); + close_fd: close(fd); return err; }