From nobody Mon Feb 9 11:32:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@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 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633623496; cv=none; d=zohomail.com; s=zohoarc; b=NXW6RHZ9HVAJlBD5bcWKfDnMa1gs0c9cQk0h6OTFIMnBg9Z91JKRwN84+WSBjxZKTK9sHxXLBJwpb8VL49uC6hbJBW5Qm76otNLD4/5iF1dM5ZqWrUZmzf8bLEKD94AfoYhohVisJ3qzTit1viiSQgorkvDodLvoaC6GvXBoUZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633623496; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=MMQ6iAvCxwnURglpVB4IW0fu5BXcN7B4HeGKo8BxsN0=; b=mDZ/ZqpaIHDABZiMGUJQlNxMKV0i2ZyBZiHn//hT60IrRZfSov0fETJL6itwU1hRgxCRKW1QMnn+uWPFY/RS3c4rdCiByYV7qFVWS6UAu1UeULEfZWM9Ah6WfyyO1TOKxTsRMCWbKs51gYmS1qT9aS69Lm2IVWu31bRQYte0JMA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 163362349698631.277737910314272; Thu, 7 Oct 2021 09:18:16 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-ji4586CSPPOo88bgoMCxiw-1; Thu, 07 Oct 2021 12:18:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id 75-20020adf82d1000000b00160cbb0f800so4357144wrc.22 for ; Thu, 07 Oct 2021 09:18:14 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id 1sm9454040wmb.24.2021.10.07.09.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 09:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633623495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MMQ6iAvCxwnURglpVB4IW0fu5BXcN7B4HeGKo8BxsN0=; b=ZOeiXkUGBkEkX/yditrrDNpj+090gGh96ZUkggENJJQZGQhW22du0f6qKEqKds0vyFVDoD pFQxM6CI6R2+K3hfcXRU9n+RaX0CYix1+nT7eOOUKvnH3y10NAChW5zvlklcpdrUMidepB X4G63hRV9f32N3DtpUGGOJjgwWbcNE4= X-MC-Unique: ji4586CSPPOo88bgoMCxiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MMQ6iAvCxwnURglpVB4IW0fu5BXcN7B4HeGKo8BxsN0=; b=6jf6Arl9qIq6S3RqD0YX+1NnGFntLBIDSkD1xN7JUFIYDAPEwKt3IDTKyfI6f7Yr7L 7NU5mBSlNQjzuI5qJXIze4DQTmFevtz7qCbtOBdGqzgyRFm1rnbEBbcosIaZH92r4KPe 8uzLXEA/CRlhC2N0bfZv+fHzJVxCE8Qt5C447BWYojnmhQZhlGBGpELdwa5ZOGvXujK+ alV7i4LrTGmHg8qvnvClZUogTYa5NNfk4gxjyZlyBIDwqlmr5mkw/PU2mMVzJTCA+glK uGC9dnrv7MW5siTBsRnJEfHQKRPLhWANbx8iKzqIHtJc0K1bwExhyAMU7+8YvuiuyZSl olXA== X-Gm-Message-State: AOAM531QDLAIqike34ogXjNbQAJI3E/9O3uwaGaRcrl/PvEeUCE8s72o EgIdoPRuH1kyYSQ/3U96NcwMoCsDEklb9ovezADsfNwInQSS8DgeRfuTW1RlyEn1Mz3A7TWXwDV r/ru8YW3LaFyafA== X-Received: by 2002:a1c:9857:: with SMTP id a84mr17228546wme.28.1633623493630; Thu, 07 Oct 2021 09:18:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ZfB3bnXzEPGWYDhd6PuaST01yQ2MZwVDhjZw+EgLXq2/Mov1UPnSHQG5FosvLqV9SCfneQ== X-Received: by 2002:a1c:9857:: with SMTP id a84mr17228508wme.28.1633623493502; Thu, 07 Oct 2021 09:18:13 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , kvm@vger.kernel.org, "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , James Bottomley , Brijesh Singh , Sergio Lopez , Dov Murik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 12/23] target/i386/sev: Use g_autofree in sev_launch_get_measure() Date: Thu, 7 Oct 2021 18:17:05 +0200 Message-Id: <20211007161716.453984-13-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211007161716.453984-1-philmd@redhat.com> References: <20211007161716.453984-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633623498816100001 Use g_autofree to remove a pair of g_free/goto. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/sev.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 3a30ba6d94a..5cbbcf0bb93 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -685,8 +685,8 @@ sev_launch_get_measure(Notifier *notifier, void *unused) { SevGuestState *sev =3D sev_guest; int ret, error; - guchar *data; - struct kvm_sev_launch_measure *measurement; + g_autofree guchar *data =3D NULL; + g_autofree struct kvm_sev_launch_measure *measurement =3D NULL; =20 if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) { return; @@ -708,7 +708,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) if (!measurement->len) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", __func__, ret, error, fw_error_to_str(errno)); - goto free_measurement; + return; } =20 data =3D g_new0(guchar, measurement->len); @@ -720,7 +720,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused) if (ret) { error_report("%s: LAUNCH_MEASURE ret=3D%d fw_error=3D%d '%s'", __func__, ret, error, fw_error_to_str(errno)); - goto free_data; + return; } =20 sev_set_guest_state(sev, SEV_STATE_LAUNCH_SECRET); @@ -728,11 +728,6 @@ sev_launch_get_measure(Notifier *notifier, void *unuse= d) /* encode the measurement value and emit the event */ sev->measurement =3D g_base64_encode(data, measurement->len); trace_kvm_sev_launch_measurement(sev->measurement); - -free_data: - g_free(data); -free_measurement: - g_free(measurement); } =20 char * --=20 2.31.1