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:
parent
359bc95d3e
commit
bb16172c52
@ -2762,11 +2762,13 @@ static int gdbserver_open(int port)
|
|||||||
ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
|
ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = listen(fd, 0);
|
ret = listen(fd, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
perror("listen");
|
perror("listen");
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
|
Loading…
Reference in New Issue
Block a user