]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/service: service_add_fd_store() consumes passed fd
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Nov 2024 20:15:49 +0000 (05:15 +0900)
committerMike Yuan <me@yhndnzj.com>
Fri, 22 Nov 2024 03:15:51 +0000 (04:15 +0100)
Without this change, the fd is closed twice on failure.

Fixes a bug introduced by dff9808a628c31b7ecb1f1aba8fdc3be06ce8372.

Fixes #35288.

src/core/service.c

index 5b0bb76af2d3ddb3e498fe86b16d8de9bfe00e0a..34d40c69508b7441e57aa6adfda13dfe1fd7ea1c 100644 (file)
@@ -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;