sim-card
/
qemu
Archived
10
0
Fork 0

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>
This commit is contained in:
Peter Maydell 2011-12-24 23:37:24 +00:00 committed by Stefan Hajnoczi
parent 359bc95d3e
commit bb16172c52
1 changed files with 2 additions and 0 deletions

View File

@ -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;