summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-02-23 03:04:44 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-02-23 03:05:59 +0100
commit63b1e67ed94fd033427ab09d7d20f879d6939e6f (patch)
treec366fef334306a3717f5ad471f9c1652b8a65495
parentsd-event: fix use of uninitialized variable (diff)
downloadsystemd-63b1e67ed94fd033427ab09d7d20f879d6939e6f.tar.xz
systemd-63b1e67ed94fd033427ab09d7d20f879d6939e6f.zip
sd-event: fix error handling
Follow-up for 158fe190afe37b222c9dc2c53bd7be426b92ef89.
-rw-r--r--src/libsystemd/sd-event/sd-event.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 403127d669..3db9122fc2 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2028,10 +2028,11 @@ _public_ int sd_event_add_memory_pressure(
return locked ? -ENOENT : -EOPNOTSUPP;
path_fd = open(watch_fallback, O_PATH|O_CLOEXEC);
- if (errno == ENOENT) /* PSI is not available in the kernel even under the fallback path? */
- return -EOPNOTSUPP;
- if (errno < 0)
+ if (path_fd < 0) {
+ if (errno == ENOENT) /* PSI is not available in the kernel even under the fallback path? */
+ return -EOPNOTSUPP;
return -errno;
+ }
}
if (fstat(path_fd, &st) < 0)