From nobody Mon Feb 9 06:34:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1573543689; cv=none; d=zoho.com; s=zohoarc; b=iF1AM048ZlVI6VZhjsUE5qlsyvkvaqebPvs2navPHAhtIrCBgjFWDROwpaazC3fK8OVu6aFea6tavFIRkouqxU2l6lsrVjSNXCPnFQ3ZJycOO/JyF51UKaVaNdDvzAMBFdCkhEq4FS3Rf7U76CrN2YC+s9ZcyZO1R+udl6rLWVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573543689; 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; bh=zaX00Y/LJy82g5K2FvJvfnhuP6HdgXiwvZCO/kCiqkA=; b=KtMI37fWKBeuvjYTrGVOTBcTJEqWpfYwGIkr57jKdep0UwYi7voVGk+fTJvMU0425IN5DFzJ7JHWntpBBKXUY29eKHwJT97KXkz8WXxjAmG/UnTQGW4O6C/RTTk9nJy9lKTK9UhhSUBCz1tP2ga8mI0I5PoWiKR05+GQFy8Nvyk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573543689087172.03796087573824; Mon, 11 Nov 2019 23:28:09 -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-386-I_qNh8ULNCiqODK1l3S6Fg-1; Tue, 12 Nov 2019 02:28:05 -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 0F9CF801E4F; Tue, 12 Nov 2019 07:28:00 +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 EB0B862671; Tue, 12 Nov 2019 07:27: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 5DB5418089CE; Tue, 12 Nov 2019 07:27:55 +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 xAC7RqTD011333 for ; Tue, 12 Nov 2019 02:27:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E8DABEA63; Tue, 12 Nov 2019 07:27:52 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A68D62671 for ; Tue, 12 Nov 2019 07:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573543687; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zaX00Y/LJy82g5K2FvJvfnhuP6HdgXiwvZCO/kCiqkA=; b=WEn15ygDIKgB+btOIZ9oHjbOP8wVSKKdGcDly+e1YZ0qrOUhw0WABBGePkOP5f7q5SedQo ++09VHsSPLJGXUaz00FvMesB1eULk7GWBxE9GXSHQYB7pOP7xfDItnI5tWuz3uBeNju0Se +9/fdAdjldiScsjkkSaYpuRH9CiWzFI= From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 08:27:38 +0100 Message-Id: <93a754894e6054b08a1bc11d2d5bfbd7c3a46b21.1573543601.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/10] qemu: caps: Rework memory allocation in virQEMUCapsFillDomainFeatureSEVCaps 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 X-MC-Unique: I_qNh8ULNCiqODK1l3S6Fg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_new0 instead of VIR_ALLOC to avoid error cases. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index fc6473651c..02ac421067 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5572,21 +5572,16 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr = qemuCaps, virDomainCapsPtr domCaps) { virSEVCapability *cap =3D qemuCaps->sevCapabilities; - g_autoptr(virSEVCapability) sev =3D NULL; if (!cap) return 0; - if (VIR_ALLOC(sev) < 0) - return -1; - - sev->pdh =3D g_strdup(cap->pdh); - - sev->cert_chain =3D g_strdup(cap->cert_chain); + domCaps->sev =3D g_new0(virSEVCapability, 1); - sev->cbitpos =3D cap->cbitpos; - sev->reduced_phys_bits =3D cap->reduced_phys_bits; - domCaps->sev =3D g_steal_pointer(&sev); + domCaps->sev->pdh =3D g_strdup(cap->pdh); + domCaps->sev->cert_chain =3D g_strdup(cap->cert_chain); + domCaps->sev->cbitpos =3D cap->cbitpos; + domCaps->sev->reduced_phys_bits =3D cap->reduced_phys_bits; return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list