From nobody Mon May 20 14:56:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1645117627; cv=none; d=zohomail.com; s=zohoarc; b=lx7UAdyOVrb0gPRIvKxDat21X+kyXKBWY+jFp9MafB/pGJ9KPQ0FJbclq55mT+hlFME9DhBsdZduLZHOsntkOBOMLJKjLOn7QS+uzXbyk54jrsoTtNFuXUWThYoh5lC7osxJC/4TRclzbVWBuKB3WLSnNRaUMZPme9ezb1h229w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645117627; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2Bpd6Kb5ibzWUzJStYNKY+51Tu+N5ef1mGNeaBYyXNk=; b=lzzlkNpdRFhleP7wCaQtXs4k6ZKdvgM+hfrgRUsWIIZB+KyJl932kcwG7J/WWAJDHd8bu5o8vtrFuec4kSeYWRpwiBQj/n5jvisEp4U42aanuHGpGtTYconus+F1Cmxu64eSPaO7xgkoa2K+UyW0JjTYFcdpDoblayFJQeH40xo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164511762782317.033231988304692; Thu, 17 Feb 2022 09:07:07 -0800 (PST) Received: from localhost ([::1]:59996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKkFF-0003Uj-Ur for importer@patchew.org; Thu, 17 Feb 2022 12:07:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKkCd-0001K5-NY for qemu-devel@nongnu.org; Thu, 17 Feb 2022 12:04:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54123) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKkCY-0000QL-Bm for qemu-devel@nongnu.org; Thu, 17 Feb 2022 12:04:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-jLrqtgltOca0e-7afRgVUw-1; Thu, 17 Feb 2022 12:04:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F078C1006AA3 for ; Thu, 17 Feb 2022 17:04:12 +0000 (UTC) Received: from localhost (unknown [10.39.195.1]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B0BB2DE9C; Thu, 17 Feb 2022 17:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645117455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2Bpd6Kb5ibzWUzJStYNKY+51Tu+N5ef1mGNeaBYyXNk=; b=CcZTtTITOoCwtpKOMuxYw92a++KmMytpP6loWU/qVbSzLDDTFKYb6PxgOD3LXxL1D2x11R CH7youYoqqlLCTyVQVkXZaXSAmUm7j3AnTCm+BwzQF9kY2NyQ8F9lOAHhOhFufPqS7wX3Q 0M38DDAyDqZ6ODhpbJQw1BBWcaC9bYc= X-MC-Unique: jLrqtgltOca0e-7afRgVUw-1 From: Hanna Reitz To: qemu-devel@nongnu.org Subject: [PATCH] migration: NULL transport_data after freeing Date: Thu, 17 Feb 2022 18:04:07 +0100 Message-Id: <20220217170407.24906-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hanna Reitz , "Dr . David Alan Gilbert" , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645117630189100001 Content-Type: text/plain; charset="utf-8" migration_incoming_state_destroy() NULLs all objects it frees after they are freed, presumably so that a subsequent call to the same function will not free them again, unless new objects have been created in the meantime. transport_data is the exception, and it shows exactly this problem: When an incoming migration uses transport_cleanup() and transport_data, and a subsequent incoming migration (e.g. loadvm) occurs that does not, then when this second one is done, it will call transport_cleanup() on the old transport_data again -- which has already been freed. This is sometimes visible in the iotest 201, though for some reason I can only reproduce it with -m32. To fix this, call transport_cleanup() only when transport_data is not NULL (otherwise there is nothing to clean up), and set transport_data to NULL when it has been cleaned up (i.e. freed). (transport_cleanup() is used only by migration/socket.c, where socket_start_incoming_migration_internal() sets both it and transport_data to non-NULL values.) Signed-off-by: Hanna Reitz --- migration/migration.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index bcc385b94b..cdb2e76d02 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -287,8 +287,9 @@ void migration_incoming_state_destroy(void) g_array_free(mis->postcopy_remote_fds, TRUE); mis->postcopy_remote_fds =3D NULL; } - if (mis->transport_cleanup) { + if (mis->transport_cleanup && mis->transport_data) { mis->transport_cleanup(mis->transport_data); + mis->transport_data =3D NULL; } =20 qemu_event_reset(&mis->main_thread_load_event); --=20 2.34.1