From nobody Sun Apr 28 05:08:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1582100814; cv=none; d=zohomail.com; s=zohoarc; b=e7EszXTI+0hxNufZtCTcgDKUZDot0Joz5cDNYXArXLDeDB/Uevt08mmaYdyCfs9r66pq8APrxun/1jpBdvr4mU5MKdWRxGdsleANpeUAd3xIZlT/h9DjhVhyND0ucEArMdqcZiMLZ0D3l1OR7LRMQxYzcrgK7AvPLiEKXDBsW8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582100814; 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=JXRLK9fB0KCAKezTwVGW/vHdA3wTW3jnaJJSObd1KX0=; b=kvzqeB33Nhm6d5hwCMzWjrAs48uHMUAO2y7cPlVDBTZFici6oDcBWcIca+E81EiaagOyeq80wi+teOBwSUCSAbcOKuliXZNtthbdBvykY9WSQuHLGmhIjBVvfNPsTjVfiiRCtcMvpzOgcrGY5UeXQ95QESYOeRV5mr5/QsYXPpM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1582100814676302.6513933566482; Wed, 19 Feb 2020 00:26:54 -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-273-obSPEwpjPqa0sb59y-198w-1; Wed, 19 Feb 2020 03:26:46 -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 974B6107ACC7; Wed, 19 Feb 2020 08:26:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25CF21001920; Wed, 19 Feb 2020 08:26:37 +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 5495118089CD; Wed, 19 Feb 2020 08:26:31 +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 01J8QTYr022515 for ; Wed, 19 Feb 2020 03:26:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6F09A88859; Wed, 19 Feb 2020 08:26:29 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E78DE88854 for ; Wed, 19 Feb 2020 08:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582100813; 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=JXRLK9fB0KCAKezTwVGW/vHdA3wTW3jnaJJSObd1KX0=; b=OB/jPRlqNIyqzTWeteeeqkLs3LG29U/YC2L3nwaKYgrBgKJ0w0F8WGplXW9DnJlSTCeKeI cUO3w2P+n7xd1ZwXLPidXs064YBOVxw3DCmktaFSFV6ZPA95m12ejxkDMPpYnMvnsc+K0I NO0zqhl6S5aCu+2gqS2AkRt9YiGPiF4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemuDomainGetStatsIOThread: Don't leak array with 0 iothreads Date: Wed, 19 Feb 2020 09:26:23 +0100 Message-Id: <635d8daf434227b9fe08650a4bc2142afbe66c96.1582100783.git.pkrempa@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 X-MC-Unique: obSPEwpjPqa0sb59y-198w-1 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" qemuMonitorGetIOThreads returns a NULL terminated list even when 0 iothreads are present. The caller didn't perform cleanup if there were 0 iothreads leaking the array. https://bugzilla.redhat.com/show_bug.cgi?id=3D1804548 Reported-by: Jing Yan Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f686b858cf..39e1f044e0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21759,8 +21759,12 @@ qemuDomainGetStatsIOThread(virQEMUDriverPtr driver, if ((niothreads =3D qemuDomainGetIOThreadsMon(driver, dom, &iothreads)= ) < 0) return -1; - if (niothreads =3D=3D 0) - return 0; + /* qemuDomainGetIOThreadsMon returns a NULL-terminated list, so we mus= t free + * it even if it returns 0 */ + if (niothreads =3D=3D 0) { + ret =3D 0; + goto cleanup; + } if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0) goto cleanup; --=20 2.24.1