On 10/3/25 18:02, Daniel P. Berrangé wrote:
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.

Signed-off-by: Daniel P. BerrangĂ© <[email protected]>
---
  io/channel-tls.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/io/channel-tls.c b/io/channel-tls.c
index 7135896f79..bb460ca7e9 100644
--- a/io/channel-tls.c
+++ b/io/channel-tls.c
@@ -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);
  }

This series should be relevant for 7.2.x qemu stable series too, it
looks like.  Except that 7.2 does not have ioc->bye_ioc_tag (which
comes from v9.2.0-1773-g30ee88622e "io: tls: Add qio_channel_tls_bye"), and does not have trace_qio_channel_tls_handshake_cancel defined.

Does the whole series (besides this change) look sane in the 7.2.x
context?

Thanks,

/mjt

Reply via email to