]> git.proxmox.com Git - mirror_qemu.git/commitdiff
contrib/plugins: Close file descriptor on error return
authorCong Liu <liucong2@kylinos.cn>
Sun, 29 Oct 2023 14:50:33 +0000 (14:50 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 31 Oct 2023 14:10:21 +0000 (14:10 +0000)
This patch closes the file descriptor fd on error return to avoid
resource leak.

Fixes: ec7ee95db909 ("contrib/plugins: fix coverity warning in lockstep")
Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Message-Id: <20231018025225.1640122-1-liucong2@kylinos.cn>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20231029145033.592566-20-alex.bennee@linaro.org>

contrib/plugins/lockstep.c

index f0cb8792c6fa7820aa20bb7dfd25695ec8c3cafd..237543b43a76a1e657ddaef150314fc295366764 100644 (file)
@@ -257,6 +257,7 @@ static bool setup_socket(const char *path)
     sockaddr.sun_family = AF_UNIX;
     if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
         perror("bad path");
+        close(fd);
         return false;
     }
 
@@ -303,6 +304,7 @@ static bool connect_socket(const char *path)
     sockaddr.sun_family = AF_UNIX;
     if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
         perror("bad path");
+        close(fd);
         return false;
     }