From nobody Mon Nov 23 04:44:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=sangfor.com.cn Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794403985053474.59151449142803; Wed, 11 Nov 2026 05:33:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR8RU-0005nQ-17; Wed, 11 Nov 2026 08:32:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7X7-0001Rj-O7 for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:34:33 -0500 Received: from mail-m1602365311.xmail.ntesmail.com ([160.236.53.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7X3-0006hA-DA for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:34:33 -0500 Received: from ubuntu.. (unknown [43.247.70.81]) by smtp.qiye.163.com (Hmail) with ESMTP id 5450e6ad7; Wed, 11 Nov 2026 20:27:12 +0800 (GMT+08:00) From: Zhu Wei To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Fabiano Rosas , zhuwei , "zachwade . k" Subject: [PATCH 1/1] migration: free migration blocker error in migrate_del_blocker() stub Date: Wed, 11 Nov 2026 20:27:11 +0800 Message-ID: <20261111122711.3167511-2-zhuwei@sangfor.com.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261111122711.3167511-1-zhuwei@sangfor.com.cn> References: <20261111122711.3167511-1-zhuwei@sangfor.com.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0aa1ca93961803a9kunm82bedf086c5195 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaGkJMVk1OTE1IGhpIHR9DGlYVFA kWGhdVEwETFhoSFyQUDg9ZV1kYEgtZQVlPSFVJT0xVTEtVQ0pZV1kWGg8SFR0UWUFZT0tIVUpLSU 9PT0hVSktLVUpCS0tZBg++ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=160.236.53.11; envelope-from=zhuwei@sangfor.com.cn; helo=mail-m1602365311.xmail.ntesmail.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 11 Nov 2026 08:32:29 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1794403989675158500 Content-Type: text/plain; charset="utf-8" From: niming The migrate_del_blocker() implementation in stubs/migr-blocker.c was an empty no-op, while the real one in migration/migration.c takes ownership of the Error from the migration blocker, frees it and then clears the pointer: void migrate_del_blocker(Error **reasonp) { if (*reasonp) { ... error_free(*reasonp); *reasonp =3D NULL; } } Command line tools such as qemu-img link against the stub API. Block drivers like vmdk allocate a migration blocker Error during open() (see error_setg() in vmdk_open(), "does not support live migration") and pass it to migrate_add_blocker_normal(). Because the stub migrate_add_blocker*() is a no-op it does not take ownership of the Error, so on close the stub migrate_del_blocker() has to free it itself; leaving the body empty leaks the error message. This becomes visible when running under ASan: "qemu-img info foo.vmdk" leaks the migration-blocker error and hangs / fails to exit when the image is closed. Free the Error in the stub migrate_del_blocker() and set the pointer to NULL to match the semantics of the real implementation. This also covers every other driver that uses a migration blocker through the stub. Signed-off-by: niming Signed-off-by: zhuwei --- stubs/migr-blocker.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stubs/migr-blocker.c b/stubs/migr-blocker.c index e54c7160d3..575b65f183 100644 --- a/stubs/migr-blocker.c +++ b/stubs/migr-blocker.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "migration/blocker.h" +#include "qapi/error.h" =20 int migrate_add_blocker(Error **reasonp, Error **errp) { @@ -18,4 +19,12 @@ int migrate_add_blocker_modes(Error **reasonp, unsigned = modes, Error **errp) =20 void migrate_del_blocker(Error **reasonp) { + /* + * migrate_add_blocker*() is a no-op here, so nobody owns the Error; + * free it to avoid a leak (e.g. "qemu-img info foo.vmdk"). + */ + if (reasonp && *reasonp) { + error_free(*reasonp); + *reasonp =3D NULL; + } } --=20 2.56.0