From nobody Tue Sep 9 03:13:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1749732785; cv=none; d=zohomail.com; s=zohoarc; b=X1Ovw8WxbCmnWs380ymZ+gpR9sf7aUifAEJJFaz64mbgGn6X4EAvmZuCGfRqaFyOLG8IDWZZQ8/B6XqcnD79ZcF1J9tTah/Yn0OwSTg0x0/V4XwbWF9Xb8kc4PPZobuexzeSDIda7Olx1Wf1T0FwtcpfrVCXuOtUYh+7Wh3TmiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749732785; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=xajBM2uKU3BmaHhxbbD8ciyvWMvas1HDlq0N1UNEPps=; b=fQ7olyAHSNYq8viBBIQMzo6v9FmGvinA/ytBYNCSTRj/p6fsdK88tE+7q9CCfctyrS9fHz4qkeywvnqp+0atGnT9yAhmso2jghX7zIPX7+e33TPgPQdY5Iiw0ZXGGQnUdRv9e0j3g/W7Y5hhCyguhiQXV2gZzTO2Y5DyLuYY3Y0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1749732785726280.46968115761; Thu, 12 Jun 2025 05:53:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B73D614B5; Thu, 12 Jun 2025 08:53:04 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8DDF213D8; Thu, 12 Jun 2025 08:49:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D6E7411AA; Thu, 12 Jun 2025 08:49:22 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 01FE1D95 for ; Thu, 12 Jun 2025 08:49:06 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-K_uBM-_AMsaAzMSkTNA8Tg-1; Thu, 12 Jun 2025 08:49:05 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCAD41956096 for ; Thu, 12 Jun 2025 12:49:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 23D6C195609D for ; Thu, 12 Jun 2025 12:49:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749732546; h=from:from: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; bh=vA2y6vdvINjppdmXztSHww9Gv/Ba9vqV6kziOu1HHnc=; b=GUIZkYoxSmfPUD9Xa8I/tPIlUakSLGXnvoE9+NFO95Z5mE62ecXncEB0Ilmr2n3rDhKrbM QdEOqORc+YBrIOp01xjPqTW2Bd9Wyf2osFJs245DjO2T1dt1FRnIDdpe6Hc5zA659ocBHw FOb5aiY70lnYj2kzGsBjRMqJEr3vkI0= X-MC-Unique: K_uBM-_AMsaAzMSkTNA8Tg-1 X-Mimecast-MFC-AGG-ID: K_uBM-_AMsaAzMSkTNA8Tg_1749732544 To: devel@lists.libvirt.org Subject: [PATCH 12/15] virt-aa-helper: Use automatic memory freeing Date: Thu, 12 Jun 2025 14:48:44 +0200 Message-ID: <0ed6ee7a0120a0d6cfd90dc060aa56b7ae7e267a.1749732372.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: pCFFSSNesFAzBr2e9QC5hSlUh8H1tpulG38NOog2Wxc_1749732544 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HFGG4T2ERBADC6DRTBB5UEZA75FVVBAG X-Message-ID-Hash: HFGG4T2ERBADC6DRTBB5UEZA75FVVBAG X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1749732787229116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Signed-off-by: Michal Privoznik --- src/security/virt-aa-helper.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 64cada3b3b..2ea4b47fa5 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -865,7 +865,7 @@ get_files(vahControl * ctl) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int rc =3D -1; size_t i; - char *uuid; + g_autofree char *uuid =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; bool needsVfio =3D false, needsvhost =3D false, needsgl =3D false; =20 @@ -1026,12 +1026,11 @@ get_files(vahControl * ctl) needsgl =3D true; } else { if (virDomainGraphicsNeedsAutoRenderNode(graphics)) { - char *defaultRenderNode =3D virHostGetDRMRenderNode(); + g_autofree char *defaultRenderNode =3D virHostGetDRMRender= Node(); needsgl =3D true; =20 if (defaultRenderNode) { vah_add_file(&buf, defaultRenderNode, "rw"); - VIR_FREE(defaultRenderNode); } } } @@ -1237,7 +1236,7 @@ get_files(vahControl * ctl) =20 for (i =3D 0; i < ctl->def->ntpms; i++) { virDomainTPMDef *tpm =3D ctl->def->tpms[i]; - char *shortName =3D NULL; + g_autofree char *shortName =3D NULL; const char *tpmpath =3D NULL; =20 if (tpm->type !=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) @@ -1276,8 +1275,6 @@ get_files(vahControl * ctl) virBufferAsprintf(&buf, " \"%s/libvirt/qemu/swtpm/%s-swtpm.pid\" rw,\n", RUNSTATEDIR, shortName); - - VIR_FREE(shortName); } =20 for (i =3D 0; i < ctl->def->nsmartcards; i++) { @@ -1362,7 +1359,6 @@ get_files(vahControl * ctl) ctl->files =3D virBufferContentAndReset(&buf); =20 cleanup: - VIR_FREE(uuid); return rc; } =20 @@ -1438,15 +1434,13 @@ vahParseArgv(vahControl * ctl, int argc, char **arg= v) } =20 if (ctl->cmd =3D=3D 'c' || ctl->cmd =3D=3D 'r') { - char *xmlStr =3D NULL; + g_autofree char *xmlStr =3D NULL; if (virFileReadLimFD(STDIN_FILENO, MAX_FILE_LEN, &xmlStr) < 0) vah_error(ctl, 1, _("could not read xml file")); =20 if (get_definition(ctl, xmlStr) !=3D 0 || ctl->def =3D=3D NULL) { - VIR_FREE(xmlStr); vah_error(ctl, 1, _("could not get VM definition")); } - VIR_FREE(xmlStr); =20 if (get_files(ctl) !=3D 0) vah_error(ctl, 1, _("invalid VM definition")); --=20 2.49.0