Fix a leak of a file descriptor in error exit paths in gdbserver_open(). Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> --- Of no great consequence, but it was in the pile of coverity complaints and it's a trivial fix.
gdbstub.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a5806ef..7d470b6 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; -- 1.7.5.4