]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: fix continue placement in clean-or-freeze error handling 42744/head
authordongshengyuan <545258830@qq.com>
Thu, 25 Jun 2026 08:40:28 +0000 (16:40 +0800)
committerdongshengyuan <545258830@qq.com>
Thu, 25 Jun 2026 08:40:28 +0000 (16:40 +0800)
When sd_bus_call() fails, the continue was inside the
'if (ret == EXIT_SUCCESS)' guard, so only the first failure skipped
adding the unit to the job waiter. On the second and subsequent
failures, the unit was still passed to bus_wait_for_units_add_unit()
despite no job being started, causing bus_wait_for_units_run() to
hang indefinitely.

Move continue outside the guard so any failure skips the waiter
registration. The guard still prevents ret from being overwritten by
a later error code.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
src/systemctl/systemctl-clean-or-freeze.c

index dfaff2adbcf3501d18fc3a4e904209465b1f8c9b..1022fd0d12f1bce3e4d5185c8d871c8f00b9cec6 100644 (file)
@@ -83,10 +83,9 @@ int verb_clean_or_freeze(int argc, char *argv[], uintptr_t _data, void *userdata
                 r = sd_bus_call(bus, m, 0, &error, NULL);
                 if (r < 0) {
                         log_error_errno(r, "Failed to %s unit %s: %s", argv[0], *name, bus_error_message(&error, r));
-                        if (ret == EXIT_SUCCESS) {
+                        if (ret == EXIT_SUCCESS)
                                 ret = r;
-                                continue;
-                        }
+                        continue;
                 }
 
                 if (w) {