From nobody Thu Apr 25 10:37:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1619165653; cv=none; d=zohomail.com; s=zohoarc; b=O6MfbIsTlvULDVmf2GUuP/5AmwVsK66cHlmKqiP3ORe8ho90Wk/KVjBviBMRqKG9Wr4J6XopqlnAiuXZzO/rZa/nF05hqcU+NA/Yj5b9Ya+estpQ4QnmUQnb/pB4KAYkZAQJ/SwMx1FmY1dNgCFuV9cjq9zy/J/hpaXJJZH+Ouw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619165653; 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=JmRm0sl6DfZnbiA5h4bFgN4aiSe5RBHrk8oIL2SZMCM=; b=F3RMrEGr77KFv8BBhIGOoFC9I0yGdMDvJgrays5ZrcNy492r9dG7At8ClW5czTqhsgB6+pvnNP5bdD/dRAKfDBNFJW4SAxzE5Bc3FSI27egeHQA8tdDmwmv4p0kK8RU1WfN8CpoKettFOLJw8EG3tNcCHxWNmVztwFPWmnfqCUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1619165653974450.0316142416559; Fri, 23 Apr 2021 01:14:13 -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-468-7_CeIkM7N9aUlVSsug_VkA-1; Fri, 23 Apr 2021 04:14:10 -0400 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 5352A802575; Fri, 23 Apr 2021 08:14:02 +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 03A6A19D9B; Fri, 23 Apr 2021 08:13:58 +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 AC30B44A58; Fri, 23 Apr 2021 08:13:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13N8Drw7024847 for ; Fri, 23 Apr 2021 04:13:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E43360939; Fri, 23 Apr 2021 08:13:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91E2E60C5E for ; Fri, 23 Apr 2021 08:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619165652; 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=JmRm0sl6DfZnbiA5h4bFgN4aiSe5RBHrk8oIL2SZMCM=; b=GQJWqN1h5eYxhok6Go6/0k+2iKhwJ3Yx1wpD3G9t6YeWCT5FmiSZtsBFtzHakBhcsNXbJh fQVtcFNRTp659ye0YzNk7LJf1K0IQHOULNiUa5f5Q2LaxqACTD0YdaxGmbKAEtrUATdYp/ NOHSpTWl2vXDMT23KH0GkUzcv8k5yls= X-MC-Unique: 7_CeIkM7N9aUlVSsug_VkA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Don't double free @node_cpus in qemuProcessSetupPid() Date: Fri, 23 Apr 2021 10:13:49 +0200 Message-Id: <20e5c5caa76e02652d263e66821abb9b7325e8e0.1619165622.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.84 on 10.5.11.23 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) Content-Type: text/plain; charset="utf-8" When placing vCPUs into CGroups the qemuProcessSetupPid() is called which then enters a for() loop (around its middle) where it calls virDomainNumaGetNodeCpumask() for each guest NUMA node. But the latter returns only a pointer not new reference/copy and thus the caller must not free it. But the variable is decorated with g_autoptr() which leads to a double free. Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 05104e3098..92c1f0ab74 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2741,8 +2741,7 @@ qemuProcessSetupPid(virDomainObj *vm, =20 /* Look for the guest NUMA node of this vCPU */ for (i =3D 0; i < virDomainNumaGetNodeCount(numatune); i++) { - g_autoptr(virBitmap) node_cpus =3D NULL; - node_cpus =3D virDomainNumaGetNodeCpumask(numatune, i); + virBitmap *node_cpus =3D virDomainNumaGetNodeCpumask(numat= une, i); =20 if (!virBitmapIsBitSet(node_cpus, id)) continue; --=20 2.26.3