From: Alex Chen Date: Tue, 10 Nov 2020 19:23:07 +0000 (+0000) Subject: plugins: Fix resource leak in connect_socket() X-Git-Tag: v5.2.0-rc2~12^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbb864ba4f7bc419a3ce473aa9436cc41b2e3dfd;p=thirdparty%2Fqemu.git plugins: Fix resource leak in connect_socket() Close the fd when the connect() fails. Reported-by: Euler Robot Signed-off-by: Alex Chen Signed-off-by: Alex Bennée Message-Id: <20201109082829.87496-2-alex.chen@huawei.com> Message-Id: <20201110192316.26397-2-alex.bennee@linaro.org> --- diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index a696673dff3..319bd44b832 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -292,6 +292,7 @@ static bool connect_socket(const char *path) if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) { perror("failed to connect"); + close(fd); return false; }