From nobody Mon Apr 29 01:06:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612382835; cv=none; d=zohomail.com; s=zohoarc; b=iHIlIk/RBq4XI32fqkD5FG6MhUnUeT2/KrCJwQj8rPZ6SvdqfHxpmWlvVyNdXHKHVLJ7AmrYQjG1gZLP1cEbiNhFOHFMVdyV7o9c6OrrNxhMSxlno4Etf0KchAotvGZI4ABHDwxUj1ChqUGGi6E1rbi1olL7Bbw+6kJlNdOcBFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612382835; 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=OvR4MPSttoEwgGBmk73UykWJ4AstT/SFEl6pYigJPiQ=; b=Mh5yU4a76uSBA5bdaLWtTxJ+cahO2tsTNwatURhApvsIjrudF35hekGAbxl6A7Ry7QwfgrS1F3xwLllrMkTLZkEJgBE4XGWTip9XC/hvNLPEnSuI0gkcxoa2az9rOrBrZc8MOZZny7O826Kj1tmBOSiNkEj4tAby9WIrvEWl5r0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612382835235165.37559585027554; Wed, 3 Feb 2021 12:07:15 -0800 (PST) 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-88-nnTlLk8xMtmwI-l8whr9uw-1; Wed, 03 Feb 2021 15:07:09 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5192192AB78; Wed, 3 Feb 2021 20:07:03 +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 1DA95100AE48; Wed, 3 Feb 2021 20:07:02 +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 96C9557DFA; Wed, 3 Feb 2021 20:06:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 113K6xc9008844 for ; Wed, 3 Feb 2021 15:06:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 14B4E722C9; Wed, 3 Feb 2021 20:06:59 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89A1B722CA for ; Wed, 3 Feb 2021 20:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612382834; 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=OvR4MPSttoEwgGBmk73UykWJ4AstT/SFEl6pYigJPiQ=; b=I8y+blhKpAvZ5FzhAPHUGKsd+mnVFIwzGPuL2wbLFxnLlxBFofkup6YC+ZFJp2hajmmLAT p8AYoUrG08s2Ztc9mdHYYT+8oyYVuXjd7DRi1dlxRsrXFCf9tWgrGXhUzunvmNxPUWYrL2 3LxrZlkO7vjySRcQ7wvM9HHM+A4lkuE= X-MC-Unique: nnTlLk8xMtmwI-l8whr9uw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] vircgroup: Don't leak @parent in virCgroupEnableMissingControllers() Date: Wed, 3 Feb 2021 21:06:52 +0100 Message-Id: <1d6d449cff3e97d7c511388fc41db1a7bd374d13.1612382812.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.22 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" A memory leak was identified in virCgroupEnableMissingControllers(): =3D=3D11680=3D=3D at 0x483EAE5: calloc (vg_replace_malloc.c:760) =3D=3D11680=3D=3D by 0x4E51780: g_malloc0 (in /usr/lib64/libglib-2.0.so.= 0.6701.0) =3D=3D11680=3D=3D by 0x4908618: virCgroupNew (vircgroup.c:701) =3D=3D11680=3D=3D by 0x49096F4: virCgroupEnableMissingControllers (vircg= roup.c:1146) =3D=3D11680=3D=3D by 0x4909B17: virCgroupNewMachineSystemd (vircgroup.c:= 1228) =3D=3D11680=3D=3D by 0x4909E94: virCgroupNewMachine (vircgroup.c:1313) =3D=3D11680=3D=3D by 0x1694FDBC: qemuInitCgroup (qemu_cgroup.c:946) =3D=3D11680=3D=3D by 0x1695046B: qemuSetupCgroup (qemu_cgroup.c:1083) =3D=3D11680=3D=3D by 0x16A60126: qemuProcessLaunch (qemu_process.c:7077) =3D=3D11680=3D=3D by 0x16A61504: qemuProcessStart (qemu_process.c:7384) =3D=3D11680=3D=3D by 0x169B84C2: qemuDomainObjStart (qemu_driver.c:6590) =3D=3D11680=3D=3D by 0x169B8776: qemuDomainCreateWithFlags (qemu_driver.= c:6641) What happens is that new virCgroup is created and stored into @parent. Then, if @tokens is not empty the for() loop is entered into where another virCgroup is created and @parent is replaced with this new virCgroup. But nothing freed the old @parent. Fixes: 77291414c7a8745cf4d2b06d3c38d269cfbcfe32 Reported-by: Andrea Bolognani Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- src/util/vircgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 15071d8b1b..9fb1b45a8f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1159,6 +1159,7 @@ virCgroupEnableMissingControllers(char *path, if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_SYSTEMD) < 0) return -1; =20 + virCgroupFree(parent); parent =3D g_steal_pointer(&tmp); } =20 --=20 2.26.2