From nobody Sun May 5 11:46:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565189190; cv=none; d=zoho.com; s=zohoarc; b=Es3qP3s6lQo0IIroxVt4csvu0zP0fc94vnbtsMLQysKtWOSFmoXe5c7pKbTkMzmNh+qGfVi/GR9ZrR0N1R4XRQu9pMpmI/96qVC1w9R07LJlOOklAsvFXZiUA55z7Xwqx1cbbFRNh5AUBWSyL2biWoZBc0D5iFzD3qT38YqBSUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565189190; 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:ARC-Authentication-Results; bh=Y3cn8cJPPjoHsFTMjN2WUYcjT3ojn9zX24x8zYtmq9Q=; b=n8zO1KRsDtywE87FG9wabDLoMWloKABBXtTXfxaeE17wtRM66WWvlsUnqrr4tiV1gQGjkjqUg4VgmJ6/curf4d7vGTN47ab3z8a8G8V5X0Cdl/RC/0s4UcoFSZj+D7EIrXDVCMyC4tiYx6PDxDodQEjJ6mEFaLXfXxZ6PFzkMzI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565189190731670.4144763188575; Wed, 7 Aug 2019 07:46:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 778AEC05AA61; Wed, 7 Aug 2019 14:46:29 +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 4C8665D9CD; Wed, 7 Aug 2019 14:46:29 +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 106C92551D; Wed, 7 Aug 2019 14:46:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x77Ejjj5030529 for ; Wed, 7 Aug 2019 10:45:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 544F380224; Wed, 7 Aug 2019 14:45:45 +0000 (UTC) Received: from unknown04D3B0C4CC7D.redhat.com (ovpn-116-53.phx2.redhat.com [10.3.116.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6E826D0B2 for ; Wed, 7 Aug 2019 14:45:44 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:45:41 -0400 Message-Id: <20190807144542.10639-2-jferlan@redhat.com> In-Reply-To: <20190807144542.10639-1-jferlan@redhat.com> References: <20190807144542.10639-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Fix possible NULL deref in qemuDomainGetResctrlMonData 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 07 Aug 2019 14:46:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If virQEMUDriverGetCapabilities returns NULL, then a subsequent deref of @caps would cause an error, so we just return failure. Found by Coverity Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f1983f33e6..ff83d1c024 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20728,7 +20728,8 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, size_t i =3D 0; size_t j =3D 0; =20 - caps =3D virQEMUDriverGetCapabilities(driver, false); + if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + return -1; =20 switch (tag) { case VIR_RESCTRL_MONITOR_TYPE_CACHE: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:46:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565189188; cv=none; d=zoho.com; s=zohoarc; b=ZvGS60bCDs2DvvYu7OG0peYxhnNGVkglHr6ufExFddvWLHSPTCFcPzfbkXpDdNYzoZiR78/2dpA8X20C1HcAk7CjctKigiG1YJ+6X19pQD8r0GDVKIJ7JKqjkoe656eihwRJUhL+pulI6B2JpcARiowhUpxjwFEqcb+bbeOXDjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565189188; 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:ARC-Authentication-Results; bh=ssgl0AlqqQ3EL8Djb8gOaSv3FdpckNW1mPtGFZCyLKA=; b=C6c4zuV4S6fkGZe35p1vclM2dMAzNs9mTyMb7jYuCAeZIlRneZK08dBz2yGiFrLAydzGPGc5AUHzbUK5mb+hHkv8QhafNZa+QYqq23W1jp0I5dVahMceQ4FzPaMLS9LHcbeWtfdEug1zvtzbz373h1iVeXnKyU8AAeHdHjWhWI4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565189188836171.85535791697703; Wed, 7 Aug 2019 07:46:28 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A8CB13001A65; Wed, 7 Aug 2019 14:46:27 +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 7FE291001284; Wed, 7 Aug 2019 14:46:27 +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 3D0BA180B536; Wed, 7 Aug 2019 14:46:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x77EjjMY030538 for ; Wed, 7 Aug 2019 10:45:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id E251E80364; Wed, 7 Aug 2019 14:45:45 +0000 (UTC) Received: from unknown04D3B0C4CC7D.redhat.com (ovpn-116-53.phx2.redhat.com [10.3.116.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 479D61E1 for ; Wed, 7 Aug 2019 14:45:45 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:45:42 -0400 Message-Id: <20190807144542.10639-3-jferlan@redhat.com> In-Reply-To: <20190807144542.10639-1-jferlan@redhat.com> References: <20190807144542.10639-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] tests: Fix memory leak in mymain 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 07 Aug 2019 14:46:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Commit d2899a648 added a new exit path, but didn't free @fakerootdir. Let's just use VIR_AUTOFREE instead to make life easier. Found by Coverity Signed-off-by: John Ferlan Reviewed-by: Michal Privoznik --- tests/virhostdevtest.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 7d15a87797..20984f3442 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -556,7 +556,7 @@ static int mymain(void) { int ret =3D 0; - char *fakerootdir; + VIR_AUTOFREE(char *) fakerootdir =3D NULL; =20 if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { fprintf(stderr, "Out of memory\n"); @@ -594,8 +594,6 @@ mymain(void) if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 - VIR_FREE(fakerootdir); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list