summaryrefslogtreecommitdiff
path: root/gdbstub.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdbstub.c')
-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;