Blame 0048-journald-fix-fd-leak-in-journal_file_empty.patch
|
Harald Hoyer |
db3a9f |
From f29938b8d28e574ae614f6db4e70478d8ccac4d0 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
db3a9f |
From: George McCollister <george.mccollister@gmail.com>
|
|
Harald Hoyer |
db3a9f |
Date: Wed, 4 Sep 2013 07:12:44 -0500
|
|
Harald Hoyer |
db3a9f |
Subject: [PATCH] journald: fix fd leak in journal_file_empty
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
Before my previous patch, journal_file_empty wasn't be called with the
|
|
Harald Hoyer |
db3a9f |
correct filename. Now that it's being called with the correct filename
|
|
Harald Hoyer |
db3a9f |
it leaks file descriptors. This patch closes the file descriptors before
|
|
Harald Hoyer |
db3a9f |
returning.
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
Signed-off-by: George McCollister <george.mccollister@gmail.com>
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
[Edit harald@redhat.com: make use of _cleanup_close_ instead]
|
|
Harald Hoyer |
db3a9f |
---
|
|
Harald Hoyer |
db3a9f |
src/journal/journal-vacuum.c | 3 ++-
|
|
Harald Hoyer |
db3a9f |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
|
|
Harald Hoyer |
db3a9f |
index ace7722..178c803 100644
|
|
Harald Hoyer |
db3a9f |
--- a/src/journal/journal-vacuum.c
|
|
Harald Hoyer |
db3a9f |
+++ b/src/journal/journal-vacuum.c
|
|
Harald Hoyer |
db3a9f |
@@ -129,8 +129,9 @@ static void patch_realtime(
|
|
Harald Hoyer |
db3a9f |
}
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
static int journal_file_empty(int dir_fd, const char *name) {
|
|
Harald Hoyer |
db3a9f |
- int fd, r;
|
|
Harald Hoyer |
db3a9f |
+ int r;
|
|
Harald Hoyer |
db3a9f |
le64_t n_entries;
|
|
Harald Hoyer |
db3a9f |
+ _cleanup_close_ int fd;
|
|
Harald Hoyer |
db3a9f |
|
|
Harald Hoyer |
db3a9f |
fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
|
|
Harald Hoyer |
db3a9f |
if (fd < 0)
|