All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fincore: fix file descriptor leak
@ 2017-04-06 21:11 Sami Kerola
  2017-04-06 21:11 ` [PATCH 2/2] libmount: " Sami Kerola
  2017-04-10 13:42 ` [PATCH 1/2] fincore: " Karel Zak
  0 siblings, 2 replies; 3+ messages in thread
From: Sami Kerola @ 2017-04-06 21:11 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/fincore.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c
index ffc02fc2c..6a29f375a 100644
--- a/misc-utils/fincore.c
+++ b/misc-utils/fincore.c
@@ -239,6 +239,7 @@ static int fincore_name(struct fincore_control *ctl,
 
 	if (fstat (fd, sb) < 0) {
 		warn(_("failed to do fstat: %s"), name);
+		close (fd);
 		return -errno;
 	}
 
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] libmount: fix file descriptor leak
  2017-04-06 21:11 [PATCH 1/2] fincore: fix file descriptor leak Sami Kerola
@ 2017-04-06 21:11 ` Sami Kerola
  2017-04-10 13:42 ` [PATCH 1/2] fincore: " Karel Zak
  1 sibling, 0 replies; 3+ messages in thread
From: Sami Kerola @ 2017-04-06 21:11 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 libmount/src/utils.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 7e028ee02..3b27135cd 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -647,18 +647,17 @@ done:
 
 static int try_write(const char *filename)
 {
-	int fd;
+	int fd, ret = 0;
 
 	if (!filename)
 		return -EINVAL;
 
 	fd = open(filename, O_RDWR|O_CREAT|O_CLOEXEC,
 			    S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
-	if (fd >= 0) {
-		close(fd);
-		return 0;
-	}
-	return -errno;
+	if (fd < 0)
+		ret = -errno;
+	close(fd);
+	return ret;
 }
 
 /**
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] fincore: fix file descriptor leak
  2017-04-06 21:11 [PATCH 1/2] fincore: fix file descriptor leak Sami Kerola
  2017-04-06 21:11 ` [PATCH 2/2] libmount: " Sami Kerola
@ 2017-04-10 13:42 ` Karel Zak
  1 sibling, 0 replies; 3+ messages in thread
From: Karel Zak @ 2017-04-10 13:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Thu, Apr 06, 2017 at 10:11:15PM +0100, Sami Kerola wrote:
>  misc-utils/fincore.c | 1 +
>  1 file changed, 1 insertion(+)

All applied, thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-10 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 21:11 [PATCH 1/2] fincore: fix file descriptor leak Sami Kerola
2017-04-06 21:11 ` [PATCH 2/2] libmount: " Sami Kerola
2017-04-10 13:42 ` [PATCH 1/2] fincore: " Karel Zak

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.