[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/32] io: Fix qio_channel_socket_close() error handling
From: |
Markus Armbruster |
Subject: |
[PULL 20/32] io: Fix qio_channel_socket_close() error handling |
Date: |
Wed, 29 Apr 2020 09:20:36 +0200 |
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call.
qio_channel_socket_close() passes @errp first to
socket_listen_cleanup(), and then, if closesocket() fails, to
error_setg_errno(). If socket_listen_cleanup() failed, this will trip
the assertion in error_setv().
Fix by ignoring a second error.
Fixes: 73564c407caedf992a1c688b5fea776a8b56ba2a
Cc: Daniel P. Berrangé <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Message-Id: <address@hidden>
---
io/channel-socket.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/io/channel-socket.c b/io/channel-socket.c
index b74f5b92a0..e1b4667087 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -704,6 +704,7 @@ qio_channel_socket_close(QIOChannel *ioc,
{
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
int rc = 0;
+ Error *err = NULL;
if (sioc->fd != -1) {
#ifdef WIN32
@@ -715,8 +716,8 @@ qio_channel_socket_close(QIOChannel *ioc,
if (closesocket(sioc->fd) < 0) {
sioc->fd = -1;
- error_setg_errno(errp, errno,
- "Unable to close socket");
+ error_setg_errno(&err, errno, "Unable to close socket");
+ error_propagate(errp, err);
return -1;
}
sioc->fd = -1;
--
2.21.1
- [PULL 00/32] Miscellaneous patches for 2020-04-29, Markus Armbruster, 2020/04/29
- [PULL 10/32] qemu-img: Reject broken -o "", Markus Armbruster, 2020/04/29
- [PULL 02/32] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt(), Markus Armbruster, 2020/04/29
- [PULL 05/32] qemu-option: Fix has_help_option()'s sloppy parsing, Markus Armbruster, 2020/04/29
- [PULL 09/32] qemu-img: Move is_valid_option_list() to qemu-img.c and rewrite, Markus Armbruster, 2020/04/29
- [PULL 03/32] qemu-options: Factor out get_opt_name_value() helper, Markus Armbruster, 2020/04/29
- [PULL 04/32] qemu-option: Fix sloppy recognition of "id=..." after ", , ", Markus Armbruster, 2020/04/29
- [PULL 06/32] test-qemu-opts: Simplify test_has_help_option() after bug fix, Markus Armbruster, 2020/04/29
- [PULL 20/32] io: Fix qio_channel_socket_close() error handling,
Markus Armbruster <=
- [PULL 31/32] libqos: Give get_machine_allocator() internal linkage, Markus Armbruster, 2020/04/29
- [PULL 07/32] qemu-option: Avoid has_help_option() in qemu_opts_parse_noisily(), Markus Armbruster, 2020/04/29
- [PULL 19/32] xen/pt: Fix flawed conversion to realize(), Markus Armbruster, 2020/04/29
- [PULL 32/32] qemu-option: pass NULL rather than 0 to the id of qemu_opts_set(), Markus Armbruster, 2020/04/29
- [PULL 08/32] qemu-img: Factor out accumulate_options() helper, Markus Armbruster, 2020/04/29
- [PULL 24/32] qga: Fix qmp_guest_suspend_{disk, ram}() error handling, Markus Armbruster, 2020/04/29
- [PULL 25/32] sam460ex: Suppress useless warning on -m 32 and -m 64, Markus Armbruster, 2020/04/29
- [PULL 27/32] bamboo, sam460ex: Tidy up error message for unsupported RAM size, Markus Armbruster, 2020/04/29
- [PULL 16/32] fdc: Fix fallback=auto error handling, Markus Armbruster, 2020/04/29
- [PULL 28/32] smbus: Fix spd_data_generate() for number of banks > 2, Markus Armbruster, 2020/04/29