summaryrefslogtreecommitdiff
path: root/src/journal/journald-kmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal/journald-kmsg.c')
-rw-r--r--src/journal/journald-kmsg.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 1730a23a97..5c7c06a14a 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -408,22 +408,30 @@ int server_open_dev_kmsg(Server *s) {
/* This will fail with EPERM on older kernels where
* /dev/kmsg is not readable. */
- if (r == -EPERM)
- return 0;
+ if (r == -EPERM) {
+ r = 0;
+ goto fail;
+ }
log_error("Failed to add /dev/kmsg fd to event loop: %s", strerror(-r));
- return -errno;
+ goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
log_error("Failed to adjust priority of kmsg event source: %s", strerror(-r));
- return -errno;
+ goto fail;
}
s->dev_kmsg_readable = true;
return 0;
+
+fail:
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+
+ return r;
}
int server_open_kernel_seqnum(Server *s) {