From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 2/2] ndctl, udev: fix a resource leak in save_unsafe_shutdown_count
Date: Fri, 10 Aug 2018 18:40:53 -0600 [thread overview]
Message-ID: <20180811004053.15392-2-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20180811004053.15392-1-vishal.l.verma@intel.com>
Static analysis reports that we leak the 'fd' in the above function. Fix
by adding a proper cleanup path that closes it.
Cc: Keith Busch <keith.busch@intel.com>
Fixes: dd8e6ff9ab00 ("ndctl: Create ndctl udev rules for dirty shutdown")
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
ndctl/ndctl-udev.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ndctl/ndctl-udev.c b/ndctl/ndctl-udev.c
index 2b4d067..7b174b6 100644
--- a/ndctl/ndctl-udev.c
+++ b/ndctl/ndctl-udev.c
@@ -110,10 +110,13 @@ static void save_unsafe_shutdown_count(struct ndctl_dimm *dimm,
goto free_usc;
if (snprintf(count, sizeof(count), "%u\n", shutdown) < 0)
- goto free_usc;
+ goto close_fd;
if (write(fd, count, strlen(count)) < 0)
- goto free_usc;
+ goto close_fd;
+
+ close_fd:
+ close(fd);
free_usc:
free(usc);
free_path:
--
2.14.4
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-08-11 0:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-11 0:40 [ndctl PATCH 1/2] ndctl: fix potential null dereference in the smart error handler Vishal Verma
2018-08-11 0:40 ` Vishal Verma [this message]
2018-08-13 14:29 ` Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180811004053.15392-2-vishal.l.verma@intel.com \
--to=vishal.l.verma@intel.com \
--cc=linux-nvdimm@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.