sd-event: fix error handling

Follow-up for 158fe190af.
This commit is contained in:
Yu Watanabe
2023-02-23 11:04:44 +09:00
parent 40c5d5d2a1
commit 63b1e67ed9

View 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)