]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lsm/apparmor: use cleanup macro 3925/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Aug 2021 13:59:26 +0000 (15:59 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Aug 2021 13:59:26 +0000 (15:59 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lsm/apparmor.c

index 6bf6c6eea783cb4c02f01010d738fc3b61c77171..a0d81ea01bd09dccdb5e3cd97b842724f0081822 100644 (file)
@@ -611,8 +611,8 @@ out:
 
 static bool file_is_yes(const char *path)
 {
+       __do_close int fd = -EBADF;
        ssize_t rd;
-       int fd;
        char buf[8]; /* we actually just expect "yes" or "no" */
 
        fd = open(path, O_RDONLY | O_CLOEXEC);
@@ -620,7 +620,6 @@ static bool file_is_yes(const char *path)
                return false;
 
        rd = lxc_read_nointr(fd, buf, sizeof(buf));
-       close(fd);
 
        return rd >= 4 && strnequal(buf, "yes\n", 4);
 }