From nobody Mon Nov 25 15:22:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600084276; cv=none; d=zohomail.com; s=zohoarc; b=d1hixtgKj5krTC1toGRgpcUio78mVoBP5w/nTLULOxKfSozsML7KnnWRGlLiPWeUQy5P0KpRDNrdtSY59WU3QC8asYZeI1/kVlTVIXeNdEymeuBRfc+Z3zzAvtEssbNG3/JKnFi9wCt7KRNtmetVmZh7C4UOjclqqi+1K54DkCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600084276; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HrXzoAZfIyOuHMCZnFysA0Xp0kQuaO9E7PlEzXQN8T0=; b=OPppwut2y1O3QW7A1a9obqZW+enByuwnHdS4nRXYtnmRAyz1FjDqtidSqUv3HzCNcxiBTcT4jz0tB55qMG+t8gRZf/m5yDm5ws70VgTuwoxTEOnB4YQHCQ9EgCt3jtbhD5pU/lUepu7QgLh5Iec0BoOTHyNgh1ETXmU6z+E7zcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1600084276186539.9193546246473; Mon, 14 Sep 2020 04:51:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-OvmVoxWfNFqMoDSFuvZoZA-1; Mon, 14 Sep 2020 07:51:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64A3818BA288; Mon, 14 Sep 2020 11:51:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37A7E5C3E0; Mon, 14 Sep 2020 11:51:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E44C48C7C3; Mon, 14 Sep 2020 11:51:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08EBp3HZ002560 for ; Mon, 14 Sep 2020 07:51:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9D401002D42; Mon, 14 Sep 2020 11:51:03 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 723D610021AA for ; Mon, 14 Sep 2020 11:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600084275; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HrXzoAZfIyOuHMCZnFysA0Xp0kQuaO9E7PlEzXQN8T0=; b=YWhhkaNSz7xs7KIsYk2LFwUQlO26KXJRxy0aKddUA+3C2kHSYZDEpzw9rRjr+GY63/h3Cl UBXx00oO3chbgl5vWWkdYg16pScPmVnOd5vo1oxBnTBKy79Ul/QKNbzIDxHOPexAlUj6YS F7Zwg84elGVjjj3KLu+jThQlstB+7I0= X-MC-Unique: OvmVoxWfNFqMoDSFuvZoZA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] qemuProcessReconnect: clear 'oldjob' Date: Mon, 14 Sep 2020 13:49:56 +0200 Message-Id: <04c0ba785af0d513fbd628c210d64db52533c0a9.1600084134.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) After we started copying the privateData pointer in qemuDomainObjRestoreJob, we should also free them once we're done with them. Register the clear function and use g_auto. Also add a check for job->cb to qemuDomainObjClearJob, to prevent freeing an uninitialized job. https://bugzilla.redhat.com/show_bug.cgi?id=3D1878450 Signed-off-by: J=C3=A1n Tomko Fixes: aca37c3fb2e8d733c2788ca4b796c153ea7ce391 --- src/qemu/qemu_domainjob.c | 3 +++ src/qemu/qemu_domainjob.h | 1 + src/qemu/qemu_process.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index e5910a11a1..3c2c6b9179 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -248,6 +248,9 @@ qemuDomainObjRestoreJob(virDomainObjPtr obj, void qemuDomainObjClearJob(qemuDomainJobObjPtr job) { + if (!job->cb) + return; + qemuDomainObjResetJob(job); qemuDomainObjResetAsyncJob(job); g_clear_pointer(&job->privateData, job->cb->freeJobPrivate); diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index eedd84c503..79f0127252 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -275,6 +275,7 @@ int qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobI= nfo, bool qemuDomainTrackJob(qemuDomainJob job); =20 void qemuDomainObjClearJob(qemuDomainJobObjPtr job); +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(qemuDomainJobObj, qemuDomainObjClearJob); =20 int qemuDomainObjInitJob(qemuDomainJobObjPtr job, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b1af35b933..a345edd7fb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8081,7 +8081,7 @@ qemuProcessReconnect(void *opaque) virQEMUDriverPtr driver =3D data->driver; virDomainObjPtr obj =3D data->obj; qemuDomainObjPrivatePtr priv; - qemuDomainJobObj oldjob; + g_auto(qemuDomainJobObj) oldjob =3D { 0 }; int state; int reason; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; --=20 2.26.2