aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2011-12-24 23:37:24 +0000
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-06 15:07:14 +0000
commitbb16172c52ac18742f3df156912c169904e92147 (patch)
tree04362893c6a2603f59f8c139427706d9db9ec2d9
parent359bc95d3e604e22fe07be62f5099148a2bb4e6f (diff)
gdbstub: Fix fd leak in gdbserver_open() error path
Fix a leak of a file descriptor in error exit paths in gdbserver_open(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
-rw-r--r--gdbstub.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdbstub.c b/gdbstub.c
index a5806ef6c4..7d470b608e 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2762,11 +2762,13 @@ static int gdbserver_open(int port)
ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
if (ret < 0) {
perror("bind");
+ close(fd);
return -1;
}
ret = listen(fd, 0);
if (ret < 0) {
perror("listen");
+ close(fd);
return -1;
}
return fd;