From nobody Fri Mar 6 22:32:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=zte.com.cn Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1750849524867522.0316866615726; Wed, 25 Jun 2025 04:05:24 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id BA1A314C9; Wed, 25 Jun 2025 07:05:23 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3E46F146A; Wed, 25 Jun 2025 07:05:06 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1BD811372; Tue, 24 Jun 2025 21:28:02 -0400 (EDT) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [160.30.148.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1D3731371 for ; Tue, 24 Jun 2025 21:28:01 -0400 (EDT) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4bRkhq701rz5DXWL for ; Wed, 25 Jun 2025 09:27:55 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl2.zte.com.cn with SMTP id 55P1RWdK049320 for ; Wed, 25 Jun 2025 09:27:32 +0800 (+08) (envelope-from liu.xuemei1@zte.com.cn) Received: from mapi (xaxapp02[null]) by mapi (Zmail) with MAPI id mid32; Wed, 25 Jun 2025 09:27:33 +0800 (CST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 58849 seconds by postgrey-1.37 at lists.libvirt.org; Tue, 24 Jun 2025 21:28:01 EDT Date: Wed, 25 Jun 2025 09:27:33 +0800 (CST) X-Zmail-TransId: 2afa685b508520c-31154 X-Mailer: Zmail v1.0 Message-ID: <20250625092733465LDt9KLFZDVzUzdTKcXSwz@zte.com.cn> Mime-Version: 1.0 From: To: Subject: =?UTF-8?B?wqBbUEFUQ0ggdjJdIHJlbW90ZS9zdHJlYW0tZXZlbnQ6IEZpeCBhIG1lbW9yeSBsZWFrIGluCgogcmVtb3RlU3RyZWFtQ2FsbGJhY2tGcmVlKCk=?= X-MAIL: mse-fl2.zte.com.cn 55P1RWdK049320 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 685B509B.000/4bRkhq701rz5DXWL X-MailFrom: liu.xuemei1@zte.com.cn X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: 22KGKDVZSJXKAMQLCDXJGNGV3F72C25L X-Message-ID-Hash: 22KGKDVZSJXKAMQLCDXJGNGV3F72C25L X-Mailman-Approved-At: Wed, 25 Jun 2025 11:05:03 -0400 CC: liu.song13@zte.com.cn X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1750849527734116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Liu Song The ff callback is never called in remoteStreamCallbackFree() because cbdata->cb can not be NULL. This causes a leak of 'cbdata->opaque'. The leak can be reproduced by attaching and detaching to the console of an VM using `virsh console`. ASAN reports the leak stack as: Direct leak of 288 byte(s) in 1 object(s) allocated from: #0 0x7f6edf6ba0c7 in calloc (/lib64/libasan.so.8+0xba0c7) #1 0x7f6edf5175b0 in g_malloc0 (/lib64/libglib-2.0.so.0+0x615b0) #2 0x7f6ede6d0be3 in g_type_create_instance (/lib64/libgobject-2.0.so.0= +0x3cbe3) #3 0x7f6ede6b82cf in g_object_new_internal (/lib64/libgobject-2.0.so.0+= 0x242cf) #4 0x7f6ede6b9877 in g_object_new_with_properties (/lib64/libgobject-2.= 0.so.0+0x25877) #5 0x7f6ede6ba620 in g_object_new (/lib64/libgobject-2.0.so.0+0x26620) #6 0x7f6edeb78138 in virObjectNew ../src/util/virobject.c:252 #7 0x7f6edeb7a78b in virObjectLockableNew ../src/util/virobject.c:274 #8 0x558251e427e1 in virConsoleNew ../tools/virsh-console.c:369 #9 0x558251e427e1 in virshRunConsole ../tools/virsh-console.c:427 Signed-off-by: Liu Song --- Changes in v2: - Fixed email formatting to ensure patch applies correctly src/remote/remote_daemon_stream.c | 2 +- src/remote/remote_driver.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 453728a66b..a5032f9a43 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -437,13 +437,13 @@ int daemonAddClientStream(virNetServerClient *client, return -1; } + virObjectRef(client); if (virStreamEventAddCallback(stream->st, 0, daemonStreamEvent, client, virObjectUnref) < 0) return -1; virObjectRef(client); - if ((stream->filterID =3D virNetServerClientAddFilter(client, daemonStreamFilter, stream)) < 0) { diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 2690c05267..9ac13469e9 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5336,7 +5336,7 @@ static void remoteStreamCallbackFree(void *opaque) { struct remoteStreamCallbackData *cbdata =3D opaque; - if (!cbdata->cb && cbdata->ff) + if (cbdata->ff) (cbdata->ff)(cbdata->opaque); virObjectUnref(cbdata->st); --=20 2.27.0