File io-release-active-GSource-in-TLS-channel.patch of Package qemu.42505
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Fri, 3 Oct 2025 14:22:12 +0100
Subject: io: release active GSource in TLS channel finalizer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
(cherry picked from commit 2c147611cf568eb1cd7dc8bf4479b272bad3b9d6)
References: bsc#1250984
[dfaggioli: remove the 'if (ioc->bye_ioc_tag)', as we don't have
30ee88622edf "io: tls: Add qio_channel_tls_bye" that
introduces bye_ioc_tag;]
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
io/channel-tls.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/io/channel-tls.c b/io/channel-tls.c
index 421d7489629c682cf987c1e60e1d..8532925cba4550e1d52491e63b4b 100644
--- a/io/channel-tls.c
+++ b/io/channel-tls.c
@@ -251,6 +251,12 @@ 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_source_remove(ioc->hs_ioc_tag);
+ ioc->hs_ioc_tag = 0;
+ }
+
object_unref(OBJECT(ioc->master));
qcrypto_tls_session_free(ioc->session);
}