[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/11] io: Fix qio_channel_socket_close() error handling
From: |
Markus Armbruster |
Subject: |
[PATCH 10/11] io: Fix qio_channel_socket_close() error handling |
Date: |
Mon, 20 Apr 2020 10:32:35 +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>
---
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
- [PATCH 00/11] Miscellaneous error handling fixes, Markus Armbruster, 2020/04/20
- [PATCH 03/11] cpus: Fix configure_icount() error API violation, Markus Armbruster, 2020/04/20
- [PATCH 06/11] fdc: Fix fallback=auto error handling, Markus Armbruster, 2020/04/20
- [PATCH 11/11] migration/colo: Fix qmp_xen_colo_do_checkpoint() error handling, Markus Armbruster, 2020/04/20
- [PATCH 05/11] arm/virt: Fix virt_machine_device_plug_cb() error API violation, Markus Armbruster, 2020/04/20
- [PATCH 10/11] io: Fix qio_channel_socket_close() error handling,
Markus Armbruster <=
- [PATCH 01/11] cryptodev: Fix cryptodev_builtin_cleanup() error API violation, Markus Armbruster, 2020/04/20
- [PATCH 02/11] block/file-posix: Fix check_cache_dropped() error handling, Markus Armbruster, 2020/04/20
- [PATCH 04/11] cpus: Proper range-checking for -icount shift=N, Markus Armbruster, 2020/04/20
- [PATCH 07/11] bochs-display: Fix vgamem=SIZE error handling, Markus Armbruster, 2020/04/20
- [PATCH 08/11] virtio-net: Fix duplex=... and speed=... error handling, Markus Armbruster, 2020/04/20
- [PATCH 09/11] xen/pt: Fix flawed conversion to realize(), Markus Armbruster, 2020/04/20