]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: fix path_cxt leak in credential loading
authorKarel Zak <kzak@redhat.com>
Wed, 20 May 2026 10:44:11 +0000 (12:44 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 20 May 2026 10:44:11 +0000 (12:44 +0200)
The ul_new_path() result was never freed. Use goto to ensure
ul_unref_path() is called on all exit paths.

Signed-off-by: Karel Zak <kzak@redhat.com>
agetty-cmd/credentials.c

index 30b12f0f71bc79c347bc4846f1b27c4fdbe55fd5..8a10b4b14a1d98b659d4df9f8c5991d60a0ebc3b 100644 (file)
@@ -109,7 +109,7 @@ void agetty_load_credentials(struct agetty_options *op)
        dir = ul_path_opendir(pc, NULL);
        if (!dir) {
                agetty_log_warn(_("failed to open credentials directory"));
-               return;
+               goto out;
        }
 
        while ((d = xreaddir(dir))) {
@@ -139,4 +139,6 @@ void agetty_load_credentials(struct agetty_options *op)
                                       &op->flags, F_ISSUE, 1);
        }
        closedir(dir);
+out:
+       ul_unref_path(pc);
 }