From: Yu Watanabe Date: Thu, 23 Feb 2023 02:04:44 +0000 (+0900) Subject: sd-event: fix error handling X-Git-Tag: v254-rc1~1181^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F26559%2Fhead;p=thirdparty%2Fsystemd.git sd-event: fix error handling Follow-up for 158fe190afe37b222c9dc2c53bd7be426b92ef89. --- diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 403127d6694..3db9122fc2e 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)