]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
io: release active GSource in TLS channel finalizer
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 3 Oct 2025 13:22:12 +0000 (14:22 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 24 Oct 2025 12:04:31 +0000 (13:04 +0100)
While code is supposed to call qio_channel_close() before releasing the
last reference on an QIOChannel, this is not guaranteed. QIOChannelFile
and QIOChannelSocket both cleanup resources in their finalizer if the
close operation was missed.

This ensures the TLS channel will do the same failsafe cleanup.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
io/channel-tls.c

index 70fad38d18c828b8e78d310f97132f039b704f3b..ce041795c19436628666c789c9ac40ca441c2093 100644 (file)
@@ -342,6 +342,16 @@ static void qio_channel_tls_finalize(Object *obj)
 {
     QIOChannelTLS *ioc = QIO_CHANNEL_TLS(obj);
 
+    if (ioc->hs_ioc_tag) {
+        trace_qio_channel_tls_handshake_cancel(ioc);
+        g_clear_handle_id(&ioc->hs_ioc_tag, g_source_remove);
+    }
+
+    if (ioc->bye_ioc_tag) {
+        trace_qio_channel_tls_bye_cancel(ioc);
+        g_clear_handle_id(&ioc->bye_ioc_tag, g_source_remove);
+    }
+
     object_unref(OBJECT(ioc->master));
     qcrypto_tls_session_free(ioc->session);
 }