From d99198819caeff6f40a0a520364e59b8a0cbaa4f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 22 Nov 2024 05:15:49 +0900 Subject: [PATCH] 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. --- src/core/service.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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;