]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-event/sd-event.c
sd-event: fix error handling
[thirdparty/systemd.git] / src / libsystemd / sd-event / sd-event.c
index 403127d66942f91e683cabadba9a65a05d48597e..3db9122fc2e89b6ba356cf16b16ec99be8417f12 100644 (file)
@@ -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)