From nobody Tue Mar 3 04:55:51 2026 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=1772457397; cv=none; d=zohomail.com; s=zohoarc; b=VCRGRPls94Jct3XAgSePnn4GiTYIuNPLThJQcpU3BNXwl7EnEGJh2vFsTWj+4b60c3STHYpQxfOqAGsA0SOBiZnRnH2lSBarPmFt5esSirlTczV695JkXP2BjzNauTN9dQuljB5Vg0ZzKS15Fri1jyPlDlF0pja8l6wLFeqyZfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772457397; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=rKbngF2WDj+1jSljlZFujQZj3j/qVUFiuN04lOYwcKg=; b=Kro/UUCcRwJ5XTFT3Vf/jHlGyhIw66tqy3m+GqNfyRw3LOUH5myAlRW4mGM9z/fOwIAMzPTUdur762jdPxE0/uvsUKwCAyrveeQ1rdcyepcTBaCJ+m8aoTKVTiNskuok3kWAqbwzEJ4iBUpRLnYfFtQUdyYLo7/qt1m0XEf3J2U= 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 1772457397172485.5467276539415; Mon, 2 Mar 2026 05:16:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 39EEF41B0E; Mon, 2 Mar 2026 08:16:36 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D9F0741B6A; Mon, 2 Mar 2026 08:15:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 0DA2F4189F; Mon, 2 Mar 2026 08:15:05 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8CB6B3F95F for ; Mon, 2 Mar 2026 08:15:04 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-GG7-E7kpNm-PvkuGG5f40A-1; Mon, 02 Mar 2026 08:15:02 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5B04180063A for ; Mon, 2 Mar 2026 13:15:01 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.44.33.137]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB2B41800576 for ; Mon, 2 Mar 2026 13:15:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772457304; 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=rKbngF2WDj+1jSljlZFujQZj3j/qVUFiuN04lOYwcKg=; b=hs3FYuPou2k98MtPyXH0hPCv0ZARQQy/8iCSypY1yYAVP9+7Ni7cDMbsTV4zq0H8AM/hju d3BX0v+6OinCdnhRCJNntXRvByg1keb/Of9yUesjNWyBInhyxQ4vqsQEgxwkGuF2vm4MOV I5O7E5CPmoLiPtfzY27CHAqC3uYRgh4= X-MC-Unique: GG7-E7kpNm-PvkuGG5f40A-1 X-Mimecast-MFC-AGG-ID: GG7-E7kpNm-PvkuGG5f40A_1772457301 To: devel@lists.libvirt.org Subject: [libvirt PATCH 1/3] security_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel Date: Mon, 2 Mar 2026 14:14:56 +0100 Message-ID: <62b67b87742b58f56b991adff4475868545a0ecb.1772457270.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7Pc8PkY2CfXgUHspS-tSfhImoBCeM96ehBWn6iXEelk_1772457301 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ECRMF7QX4OKXDZAY4DGVDEDC2FSVF64V X-Message-ID-Hash: ECRMF7QX4OKXDZAY4DGVDEDC2FSVF64V X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1772457398285158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Signed-off-by: Pavel Hrdina --- src/security/security_apparmor.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 6c5da2a650..74c5b10063 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -799,7 +799,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, virDomainHostdevDef *dev, const char *vroot) { - struct SDPDOP *ptr; + g_autofree struct SDPDOP *ptr =3D NULL; int ret =3D -1; virSecurityLabelDef *secdef =3D virDomainDefGetSecurityLabelDef(def, SECURITY_APPARMOR_NAME); @@ -831,13 +831,12 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *m= gr, =20 switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - virUSBDevice *usb =3D + g_autoptr(virUSBDevice) usb =3D virUSBDeviceNew(usbsrc->bus, usbsrc->device, vroot); if (!usb) goto done; =20 ret =3D virUSBDeviceFileIterate(usb, AppArmorSetSecurityUSBLabel, = ptr); - virUSBDeviceFree(usb); break; } =20 @@ -850,13 +849,12 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *m= gr, =20 if (pcisrc->driver.name =3D=3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_= VFIO) { if (dev->source.subsys.u.pci.driver.iommufd !=3D VIR_TRISTATE_= BOOL_YES) { - char *vfioGroupDev =3D virPCIDeviceGetIOMMUGroupDev(pci); + g_autofree char *vfioGroupDev =3D virPCIDeviceGetIOMMUGrou= pDev(pci); =20 if (!vfioGroupDev) { goto done; } ret =3D AppArmorSetSecurityPCILabel(pci, vfioGroupDev, ptr= ); - VIR_FREE(vfioGroupDev); } else { g_autofree char *vfiofdDev =3D NULL; =20 @@ -877,7 +875,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: { virDomainHostdevSubsysSCSIHost *scsihostsrc =3D &scsisrc->u.host; - virSCSIDevice *scsi =3D + g_autoptr(virSCSIDevice) scsi =3D virSCSIDeviceNew(NULL, scsihostsrc->adapter, scsihostsrc->bus, scsihostsrc->target, scsihostsrc->unit, @@ -887,13 +885,11 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *m= gr, goto done; =20 ret =3D virSCSIDeviceFileIterate(scsi, AppArmorSetSecuritySCSILabe= l, ptr); - virSCSIDeviceFree(scsi); - break; } =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: { - virSCSIVHostDevice *host =3D virSCSIVHostDeviceNew(hostsrc->wwpn); + g_autoptr(virSCSIVHostDevice) host =3D virSCSIVHostDeviceNew(hosts= rc->wwpn); =20 if (!host) goto done; @@ -901,19 +897,16 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *m= gr, ret =3D virSCSIVHostDeviceFileIterate(host, AppArmorSetSecurityHostLabel, ptr); - virSCSIVHostDeviceFree(host); break; } =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { - char *vfiodev =3D NULL; + g_autofree char *vfiodev =3D NULL; =20 if (!(vfiodev =3D virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuids= tr))) goto done; =20 ret =3D AppArmorSetSecurityHostdevLabelHelper(vfiodev, ptr); - - VIR_FREE(vfiodev); break; } =20 @@ -923,7 +916,6 @@ AppArmorSetSecurityHostdevLabel(virSecurityManager *mgr, } =20 done: - VIR_FREE(ptr); return ret; } =20 --=20 2.53.0