From: Yu Watanabe Date: Thu, 21 Nov 2024 20:15:49 +0000 (+0900) Subject: core/service: service_add_fd_store() consumes passed fd X-Git-Tag: v257-rc3~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d99198819caeff6f40a0a520364e59b8a0cbaa4f;p=thirdparty%2Fsystemd.git core/service: service_add_fd_store() consumes passed fd Without this change, the fd is closed twice on failure. Fixes a bug introduced by dff9808a628c31b7ecb1f1aba8fdc3be06ce8372. Fixes #35288. --- diff --git a/src/core/service.c b/src/core/service.c index 5b0bb76af2d..34d40c69508 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3426,14 +3426,12 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, return 0; } - r = service_add_fd_store(s, fd, fdn, do_poll); + r = service_add_fd_store(s, TAKE_FD(fd), fdn, do_poll); if (r < 0) { log_unit_debug_errno(u, r, "Failed to store deserialized fd '%s', ignoring: %m", fdn); return 0; } - - TAKE_FD(fd); } else if (streq(key, "extra-fd")) { _cleanup_free_ char *fdv = NULL, *fdn = NULL; _cleanup_close_ int fd = -EBADF;