From nobody Fri May 10 09:44:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1646224445; cv=none; d=zohomail.com; s=zohoarc; b=C/7MHrvTwgyO5ydOwdYVH9VLU/LlzSWCBYBx03fNOhpyCFxJEFvafl78V0Yuw+D7+okBRMsIfsPJt+AVfDu6Oib8qAonnSItEw8RhIr5uq27jc+E492cqgWOqP8ctOIEDsVSOkDCvo63LK3UJ2RTxXYnIMT4rC1rmON9I7cfIl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646224445; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xPPyJCU/R3HgKRh30zYEgIq5rYFpXWnXjSRHHbIRFwQ=; b=Jg08P1RZSaIGfq/PJqJ4xUxwU+whUDup6M++hoHVtPfxL3HBb8Xn2OrMuyHx0pDcigkZ62jjoDsp4hGMjxfCE/DyqfX00LH4e4n5FsnP/kHMvwFIoXhpX8NAcxn1TvKgckMct5M1I4tAxk0WcVKuQP5zrzOGonSl5N2Mc4urqx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646224445714147.58308042402734; Wed, 2 Mar 2022 04:34:05 -0800 (PST) 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-359--u1mTa3FP0ebPk211dH0HA-1; Wed, 02 Mar 2022 07:34:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A4F9824FA7; Wed, 2 Mar 2022 12:33:58 +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 071AB832B7; Wed, 2 Mar 2022 12:33:57 +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 BE3BE4EE45; Wed, 2 Mar 2022 12:33:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 222CXrta011072 for ; Wed, 2 Mar 2022 07:33:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2C30683088; Wed, 2 Mar 2022 12:33:53 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB4204F843 for ; Wed, 2 Mar 2022 12:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646224445; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xPPyJCU/R3HgKRh30zYEgIq5rYFpXWnXjSRHHbIRFwQ=; b=gZ52DMTeAbmIZ+GFepowAgTZLueGpQiVIYIesWt5arUFutojumkoXS8paSgG2N524szf0M 5IP64sWAJ4Dind0cqmnCaTRyL7aerC5DThUGCGfiZlkKCnfDA7m3vQsnz3NlBAJ5NDT0cU S2dvdrxj3Q8+6p3vvqU1qp1B04Lm9tI= X-MC-Unique: -u1mTa3FP0ebPk211dH0HA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH] qemu: domainjob: Allow free if cb is not set in qemuDomainObjClearJob Date: Wed, 2 Mar 2022 13:33:42 +0100 Message-Id: <3f844dcb180fcd38965a60dcbdd6a7bd7d1ecbb0.1646224381.git.khanicov@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646224446907100001 Content-Type: text/plain; charset="utf-8" We should allow resetting and freeing qemuDomainJobObj even if 'cb' attribute is not set. This is theoretical for now, but the attribute must not be always set in the future, so early return would create memory leaks. It is sufficient to check if 'cb' exists before dereferencing it in qemuDomainObjClearJob() and also qemuDomainObjResetAsyncJob() as the latter is called from the former. This commit partially reverts af16e754cd4efc3ca1. Signed-off-by: Kristina Hanicova --- src/qemu/qemu_domainjob.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 3e73eba4ed..587c166d94 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -239,8 +239,10 @@ qemuDomainObjResetAsyncJob(qemuDomainJobObj *job) job->abortJob =3D false; VIR_FREE(job->error); g_clear_pointer(&job->current, virDomainJobDataFree); - job->cb->resetJobPrivate(job->privateData); job->apiFlags =3D 0; + + if (job->cb) + job->cb->resetJobPrivate(job->privateData); } =20 int @@ -270,16 +272,15 @@ qemuDomainObjRestoreJob(virDomainObj *obj, void qemuDomainObjClearJob(qemuDomainJobObj *job) { - if (!job->cb) - return; - qemuDomainObjResetJob(job); qemuDomainObjResetAsyncJob(job); - g_clear_pointer(&job->privateData, job->cb->freeJobPrivate); g_clear_pointer(&job->current, virDomainJobDataFree); g_clear_pointer(&job->completed, virDomainJobDataFree); virCondDestroy(&job->cond); virCondDestroy(&job->asyncCond); + + if (job->cb) + g_clear_pointer(&job->privateData, job->cb->freeJobPrivate); } =20 bool --=20 2.35.1