gdbstub: Fix double close() of the follow-fork-mode socket
commit6971998e241d8edc842b165b447f706c05166ae6
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 12 Mar 2024 00:07:01 +0000 (12 01:07 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Wed, 13 Mar 2024 11:43:52 +0000 (13 11:43 +0000)
tree5f63ec6012b3bf3918119d6c54ac9228175c3b88
parentbbc0543b1b8231eb9712aa9b93091a1ccb2a08cd
gdbstub: Fix double close() of the follow-fork-mode socket

When the terminal GDB_FORK_ENABLED state is reached, the coordination
socket is not needed anymore and is therefore closed. However, if there
is a communication error between QEMU gdbstub and GDB, the generic
error handling code attempts to close it again.

Fix by closing it later - before returning - instead.

Fixes: Coverity CID 1539966
Fixes: d547e711a8a5 ("gdbstub: Implement follow-fork-mode child")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240312001813.13720-1-iii@linux.ibm.com>
gdbstub/user.c