From nobody Sat Feb 7 13:46:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@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 170.10.129.124 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=1643640853; cv=none; d=zohomail.com; s=zohoarc; b=bT9c5CFAMt6OMmoRvFHCQNi8pVZboZyvhCCnW7vQ9FPAWgoyWx3qm8qlKJNOVOyx0Ov6EmAadKCt7Vj91y46PZhPuDw3epMnJJtECpfgo4pQc6wAx5OnwWgQuRFmJz5MdGgGxW6VuN1kGxMjwMcJPuMZM1KTfRwyxnJszzovDPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643640853; 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=rD02HXYHXrqM266kD+yBOFzA4UpTUCuDB2qYLOuotbQ=; b=UISgb5iPhvABTnz3aeh9eZeCUh/ZZkhz21UWmOvSxhxQCFRks1JbRxAW2+1U9NYgOPERKuxRDivdT/2rFI46CO58rElqZVA6GJTlThBkOxQTT/XeYMJzJ7kqUTuZyp233FjBHVc467i6qhlgvorD6mxg/PpzX8HgoVE9R8xQ6h8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643640853457330.42761853617753; Mon, 31 Jan 2022 06:54:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-L0vm1xxMP6Ga1z9DmqPa7Q-1; Mon, 31 Jan 2022 09:54:09 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDF3284B9A5; Mon, 31 Jan 2022 14:54:03 +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 A72FF10694D9; Mon, 31 Jan 2022 14:54:03 +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 615C34BB7C; Mon, 31 Jan 2022 14:54:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20VErtwT004660 for ; Mon, 31 Jan 2022 09:53:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD24884A1A; Mon, 31 Jan 2022 14:53:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EA5F84A3E for ; Mon, 31 Jan 2022 14:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643640852; 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=rD02HXYHXrqM266kD+yBOFzA4UpTUCuDB2qYLOuotbQ=; b=jEsaDXqk0ris2yauVLV8jgz/Aotm5NI/OFUAfvRKE7EWtRHLQf1oxdht/ZBDYCaq/BRi+g Bc6wh6fyQ9U2W0mya9CXM+x/YA9Mp3A7efGG1G+G5449piX6dUv+k6Apw0Je4WWhKMav2d NbJovzl9YnkhMS9Hb/yAXY8bC0iSBiA= X-MC-Unique: L0vm1xxMP6Ga1z9DmqPa7Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] test_driver: Don't leak @group_name Date: Mon, 31 Jan 2022 15:53:39 +0100 Message-Id: <24f31f7b178c00470f802fb2553c3d83859df0f1.1643640752.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643640856000100001 Content-Type: text/plain; charset="utf-8" In testDomainSetBlockIoTune() the info.group_name is strdup()-ed and just after the whole @info structure is passed to virDomainDiskSetBlockIOTune() the @group_name member is set to NULL. This creates a memleak, because virDomainDiskSetBlockIOTune() creates its own copy of the string. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/test/test_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 1504334c30..9e1fc65972 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4027,7 +4027,6 @@ testDomainSetBlockIoTune(virDomainPtr dom, #undef TEST_BLOCK_IOTUNE_MAX_CHECK =20 virDomainDiskSetBlockIOTune(conf_disk, &info); - info.group_name =3D NULL; =20 ret =3D 0; cleanup: --=20 2.34.1 From nobody Sat Feb 7 13:46:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@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 170.10.133.124 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=1643640974; cv=none; d=zohomail.com; s=zohoarc; b=DPiMTLIPXYQNg6zV+dPSqog/QNO10wtvwRu20YG128XLuJ4rF4Zx23F3wZZSCWcQw2PPhMnwzvTeQLOBEOGt7g0kcmaziZiiiS8ZIgI4+zyDThmyVdsoLOcMJT7RMWk46m+2yMNd9psgJqMTgcDUrjVhSrULYPjllVagUk9iI9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643640974; 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=lLw7zfJh9uNVtIGzD09Rtpt+vDRVGZ4jM2/NAZpc6jo=; b=R9+4gJsfhNvk4GzOSCYDKFrXL/G1awWPS4YLiLSmfsg3ZlZyKyQCXwzVDtcoOIEfTIt4Ptt3p4BXNtPLmDABWjslsgUI+knOwycBMXx050R9Kprva+XYq3zmK1SseIWqfRPm9Cl0BjV+Lmx2S3WPot09WXqXc6/FuEiZK7MX9aI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643640974295323.11407964475654; Mon, 31 Jan 2022 06:56:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-cfiY0g04N3WGvhWYCgCYdw-1; Mon, 31 Jan 2022 09:54:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD9EB1091DA9; Mon, 31 Jan 2022 14:54:06 +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 65E1E2E05D; Mon, 31 Jan 2022 14:54:06 +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 32EDF180B617; Mon, 31 Jan 2022 14:54:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20VErubZ004677 for ; Mon, 31 Jan 2022 09:53:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id B81BD84A3E; Mon, 31 Jan 2022 14:53:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A57B84A1A for ; Mon, 31 Jan 2022 14:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643640973; 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=lLw7zfJh9uNVtIGzD09Rtpt+vDRVGZ4jM2/NAZpc6jo=; b=ecZPWawkLwttR7ggdJulat2qiy1fkrIxbVGCS25mSlgZZBjTVTlHNXe06RXkx6s3gCnwb1 yBISRolpTq45jN1ndu+DJel7JNhVaqfit21cXbIHuSK36FJrd6o3582TgxVux0HavMULLa CHP1Va1YVhdxL9NQKVTnmWX1bJogygE= X-MC-Unique: cfiY0g04N3WGvhWYCgCYdw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] lib: Don't set variable to NULL after VIR_FREE() Date: Mon, 31 Jan 2022 15:53:40 +0100 Message-Id: <5c4fbcaabba0e0becfff2bd2da82443a03fee1ef.1643640752.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643640976525100001 Content-Type: text/plain; charset="utf-8" There are a few places where a variable is VIR_FREE()-d and then explicitly set to NULL. This is not necessary since VIR_FREE() does that for us. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/domain_conf.c | 1 - src/conf/nwfilter_conf.c | 1 - tests/virtypedparamtest.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 58e696416d..e931aef6c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12746,7 +12746,6 @@ virDomainGraphicsDefNew(virDomainXMLOption *xmlopt) if (xmlopt && xmlopt->privateData.graphicsNew && !(def->privateData =3D xmlopt->privateData.graphicsNew())) { VIR_FREE(def); - def =3D NULL; } =20 return def; diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 3fedfdde56..c886218dde 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1813,7 +1813,6 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, if (match && STREQ(match, "no")) match_flag =3D NWFILTER_ENTRY_ITEM_FLAG_IS_NEG; VIR_FREE(match); - match =3D NULL; =20 while (att[idx].name !=3D NULL) { prop =3D virXMLPropString(node, att[idx].name); diff --git a/tests/virtypedparamtest.c b/tests/virtypedparamtest.c index 87b47ba86e..5ced453be5 100644 --- a/tests/virtypedparamtest.c +++ b/tests/virtypedparamtest.c @@ -106,7 +106,6 @@ testTypedParamsFilter(const void *opaque G_GNUC_UNUSED) goto cleanup; } VIR_FREE(filtered); - filtered =3D NULL; =20 nfiltered =3D virTypedParamsFilter(params, G_N_ELEMENTS(params), "bar", &filtered); --=20 2.34.1 From nobody Sat Feb 7 13:46:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@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 170.10.129.124 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=1643640851; cv=none; d=zohomail.com; s=zohoarc; b=bke+M8wB/bFYDwWhtOgpqs451PiImQdZxZZ0JFtJShSXmU7k6yzMNaEpRpbHyv9/jHOKwI5ENI8bbwdhDdmcHxNLr+4vYIiDFck91fYnH6WjS1R4LLKKhfETCu3eYGEJ+3jy7NWb0vUQdSJ0gO501X64WCQMYI5H5QZQn6z8hvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643640851; 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=DVu7xudJHFMlJEGQ16sdmECAUdzg25Ruv2wxkfyimLo=; b=Z0yFW4OYKHihiLvS0S+3Um/xoxm8m6s7p9ZZn9wPU5LfWi+d7u++Ic4zkz6bH1AV6wtfp820saWHjHZnL/iUdLc+Zm67JipxHfbOgZpxgxJe+hj4D6pYLxLlIZqp8U6ZlszqQGbYlCCZE6r14cNfgdxbJi0VuwbN2iTDXCaI3H8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643640850992668.5167451940398; Mon, 31 Jan 2022 06:54:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-m5dr0jGIOb-rY5c-4-sZnQ-1; Mon, 31 Jan 2022 09:54:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A0DC1006AA5; Mon, 31 Jan 2022 14:54:04 +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 DADCD70D2E; Mon, 31 Jan 2022 14:54:03 +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 A1AE94A7C9; Mon, 31 Jan 2022 14:54:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20VErvbT004684 for ; Mon, 31 Jan 2022 09:53:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 930AD84A1A; Mon, 31 Jan 2022 14:53:57 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15B5184A3E for ; Mon, 31 Jan 2022 14:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643640850; 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=DVu7xudJHFMlJEGQ16sdmECAUdzg25Ruv2wxkfyimLo=; b=B5NQzQsRr7RqjrfUbnNULRnOC6UUw6/+Jprq1mE8Iv5RZ5KANZI/DjEDskQzmCi0CAY+Yb oaUuRkTNHM/owY9ylqdgsEtP2UEBZE5RpkvedVrpA12389UmkAfgXHXg4ATvEXMOhT4I9a OFzwpq+9Ew41qBi4P92Y35B0pT7RnDI= X-MC-Unique: m5dr0jGIOb-rY5c-4-sZnQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] virpcivpdtest: Fix potential double-free() Date: Mon, 31 Jan 2022 15:53:41 +0100 Message-Id: <02e657f43e229deb0ee97639b14edda647a7ef51.1643640752.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643640853355100001 Content-Type: text/plain; charset="utf-8" Inside the testPCIVPDResourceCustomCompareIndex() function we have two variables @a and @b, both marked as g_autoptr(). Then, towards the end of the function b->value is freed and set to a->value. This is to make sure virPCIVPDResourceCustomCompareIndex() works correctly even if ->value member is the same for both arguments. Nevertheless, if the function returns anything else than 0 then the control executes subsequent return statement and since b->value points to the very same string as a->value a double free will occur. Avoid this by setting b->value to NULL explicitly, just like we are already doing for the successful path. Signed-off-by: Michal Privoznik --- tests/virpcivpdtest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/virpcivpdtest.c b/tests/virpcivpdtest.c index a6bf46b103..a5f4abae6f 100644 --- a/tests/virpcivpdtest.c +++ b/tests/virpcivpdtest.c @@ -229,8 +229,10 @@ testPCIVPDResourceCustomCompareIndex(const void *data = G_GNUC_UNUSED) /* Different index, same value pointers */ g_free(b->value); b->value =3D a->value; - if (virPCIVPDResourceCustomCompareIndex(b, a)) + if (virPCIVPDResourceCustomCompareIndex(b, a)) { + b->value =3D NULL; return -1; + } =20 b->value =3D NULL; =20 --=20 2.34.1 From nobody Sat Feb 7 13:46:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@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 170.10.133.124 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=1643640863; cv=none; d=zohomail.com; s=zohoarc; b=H6SbGUlr3MQJGDFbNCuHiQkTpxneJREJiapuxlqpljFhwwRQPXplftGqg+6L13sGc6J01tldlKMXb94xPqJxROt9GrNEQ9Iqvpw75HQuE1WNuhXuu08Jrcx7mkFSMt0DhN0J9l6FQRa8vVc86r6cYtJ5IVR4yfp8pfx7riUiiIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643640863; 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=m2zXp2iE3NNi7PA0Q5kFWtoXNhRqpgVciQ8RyMuHDNI=; b=PfkozlxIa9FpedgNoTkgRDDnPq+1AJVwhz2NB8wOcDI4781vrBknXpVzSKisvwyPLjwGaCztw967q5vLQVNDjUhmhv4tlQnkFuFoeZ7k7AI69Wkd2o9GVaR7IbXFp4aWF3G8jH2PhK0hjPrpWsNTODONMAsFmWqs2xXo0RaLJYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 164364086300750.77561450417522; Mon, 31 Jan 2022 06:54:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-KMTQ6LLIOcOTfdvZPxA6IA-1; Mon, 31 Jan 2022 09:54:12 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E58884B9AC; Mon, 31 Jan 2022 14:54:07 +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 EFE652E058; Mon, 31 Jan 2022 14:54:06 +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 616901806D03; Mon, 31 Jan 2022 14:54:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20VErwHE004689 for ; Mon, 31 Jan 2022 09:53:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E32684A3E; Mon, 31 Jan 2022 14:53:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id E42C284A1A for ; Mon, 31 Jan 2022 14:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643640862; 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=m2zXp2iE3NNi7PA0Q5kFWtoXNhRqpgVciQ8RyMuHDNI=; b=UWfN/WCjDKOBaAQgSZSRkYXiocndiBp3aozvXY4aU0vy9jEXuBDMBCgg6LRySJBBBRUpGo F/PKfBlgaoo9HgKnSnLwzq0TcFMHXdVz7PClgtyGxQyUIIqke5IMt4IpsrSYy2IeLS7jFI 4+L49moi251PhX6EC1dTHVHujXclTZc= X-MC-Unique: KMTQ6LLIOcOTfdvZPxA6IA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] src: Use g_steal_pointer() more Date: Mon, 31 Jan 2022 15:53:42 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643640864889100001 Content-Type: text/plain; charset="utf-8" There are few places where the g_steal_pointer() is open coded. Switch them to calling the g_steal_pointer() function instead. Generated by the following spatch: @ rule1 @ expression a, b; @@ <... - b =3D a; ... when !=3D b - a =3D NULL; + b =3D g_steal_pointer(&a); ...> Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/esx/esx_vi.c | 6 ++---- src/hyperv/hyperv_driver.c | 8 +++----- src/hyperv/hyperv_wmi.c | 3 +-- src/hypervisor/virhostdev.c | 3 +-- src/libxl/xen_common.c | 12 ++++-------- src/qemu/qemu_hotplug.c | 6 ++---- src/qemu/qemu_migration.c | 9 +++------ src/storage/storage_backend_gluster.c | 9 +++------ src/storage/storage_util.c | 6 ++---- src/util/virfile.c | 3 +-- src/util/virlease.c | 3 +-- src/util/virnuma.c | 9 +++------ 12 files changed, 26 insertions(+), 51 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 80ed6199e3..17401f0a36 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -1033,8 +1033,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) if (root !=3D ctx->service->rootFolder) esxVI_ManagedObjectReference_Free(&root); =20 - root =3D folder->_reference; - folder->_reference =3D NULL; + root =3D g_steal_pointer(&folder->_reference); } else { /* Try to lookup item as a datacenter */ if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datace= nter, @@ -1087,8 +1086,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) if (root !=3D ctx->datacenter->hostFolder) esxVI_ManagedObjectReference_Free(&root); =20 - root =3D folder->_reference; - folder->_reference =3D NULL; + root =3D g_steal_pointer(&folder->_reference); } else { /* Try to lookup item as a compute resource */ if (esxVI_LookupComputeResource(ctx, item, root, NULL, diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 7b684e04ba..52851ac507 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1780,8 +1780,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthP= tr auth, =20 priv->version =3D g_strdup(os->data->Version); =20 - conn->privateData =3D priv; - priv =3D NULL; + conn->privateData =3D g_steal_pointer(&priv); result =3D VIR_DRV_OPEN_SUCCESS; =20 cleanup: @@ -3518,9 +3517,8 @@ hypervConnectListAllDomains(virConnectPtr conn, doms[count++] =3D domain; } =20 - if (doms) - *domains =3D doms; - doms =3D NULL; + if (domains) + *domains =3D g_steal_pointer(&doms); ret =3D count; =20 cleanup: diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 6712ef4835..83d28b22aa 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -994,8 +994,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQuery *= wqlQuery, response =3D NULL; } =20 - *list =3D head; - head =3D NULL; + *list =3D g_steal_pointer(&head); =20 return 0; } diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index e44eb7f1d3..bcd5e96c2c 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -586,8 +586,7 @@ virHostdevRestoreNetConfig(virDomainHostdevDef *hostdev, */ if (MAC) { VIR_FREE(adminMAC); - adminMAC =3D MAC; - MAC =3D NULL; + adminMAC =3D g_steal_pointer(&MAC); } =20 ignore_value(virNetDevSetNetConfig(linkdev, vf, diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index fc975f1299..b97ba0a199 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -682,9 +682,8 @@ xenParseVfb(virConf *conf, virDomainDef *def) if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc= .keymap) < 0) goto cleanup; def->graphics =3D g_new0(virDomainGraphicsDef *, 1); - def->graphics[0] =3D graphics; + def->graphics[0] =3D g_steal_pointer(&graphics); def->ngraphics =3D 1; - graphics =3D NULL; } else { if (xenConfigGetBool(conf, "sdl", &val, 0) < 0) goto cleanup; @@ -696,9 +695,8 @@ xenParseVfb(virConf *conf, virDomainDef *def) if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->= data.sdl.xauth) < 0) goto cleanup; def->graphics =3D g_new0(virDomainGraphicsDef *, 1); - def->graphics[0] =3D graphics; + def->graphics[0] =3D g_steal_pointer(&graphics); def->ngraphics =3D 1; - graphics =3D NULL; } } } @@ -774,9 +772,8 @@ xenParseVfb(virConf *conf, virDomainDef *def) VIR_FREE(listenAddr); } def->graphics =3D g_new0(virDomainGraphicsDef *, 1); - def->graphics[0] =3D graphics; + def->graphics[0] =3D g_steal_pointer(&graphics); def->ngraphics =3D 1; - graphics =3D NULL; } else { if (xenHandleConfGetValueStringListErrors(rc) < 0) goto cleanup; @@ -953,9 +950,8 @@ xenParseCharDev(virConf *conf, virDomainDef *def, const= char *nativeFormat) =20 chr->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; chr->target.port =3D 0; - def->parallels[0] =3D chr; + def->parallels[0] =3D g_steal_pointer(&chr); def->nparallels++; - chr =3D NULL; } =20 /* Try to get the list of values to support multiple serial ports = */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d801559057..c9548d7f35 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4297,8 +4297,7 @@ qemuDomainChangeGraphics(virQEMUDriver *driver, =20 /* Steal the new dev's char * reference */ VIR_FREE(olddev->data.vnc.auth.passwd); - olddev->data.vnc.auth.passwd =3D dev->data.vnc.auth.passwd; - dev->data.vnc.auth.passwd =3D NULL; + olddev->data.vnc.auth.passwd =3D g_steal_pointer(&dev->data.vn= c.auth.passwd); olddev->data.vnc.auth.validTo =3D dev->data.vnc.auth.validTo; olddev->data.vnc.auth.expires =3D dev->data.vnc.auth.expires; olddev->data.vnc.auth.connected =3D dev->data.vnc.auth.connect= ed; @@ -4345,8 +4344,7 @@ qemuDomainChangeGraphics(virQEMUDriver *driver, =20 /* Steal the new dev's char * reference */ VIR_FREE(olddev->data.spice.auth.passwd); - olddev->data.spice.auth.passwd =3D dev->data.spice.auth.passwd; - dev->data.spice.auth.passwd =3D NULL; + olddev->data.spice.auth.passwd =3D g_steal_pointer(&dev->data.= spice.auth.passwd); olddev->data.spice.auth.validTo =3D dev->data.spice.auth.valid= To; olddev->data.spice.auth.expires =3D dev->data.spice.auth.expir= es; olddev->data.spice.auth.connected =3D dev->data.spice.auth.con= nected; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2635ef1162..09b8c415f4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3029,8 +3029,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, if (mig->lockState) { VIR_DEBUG("Received lockstate %s", mig->lockState); VIR_FREE(priv->lockState); - priv->lockState =3D mig->lockState; - mig->lockState =3D NULL; + priv->lockState =3D g_steal_pointer(&mig->lockState); } else { VIR_DEBUG("Received no lockstate"); } @@ -5598,8 +5597,7 @@ qemuMigrationDstPersist(virQEMUDriver *driver, error: virDomainDefFree(vm->newDef); vm->persistent =3D oldPersist; - vm->newDef =3D oldDef; - oldDef =3D NULL; + vm->newDef =3D g_steal_pointer(&oldDef); return -1; } =20 @@ -5778,8 +5776,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, } =20 if (mig->jobInfo) { - jobInfo =3D mig->jobInfo; - mig->jobInfo =3D NULL; + jobInfo =3D g_steal_pointer(&mig->jobInfo); =20 if (jobInfo->sent && timeReceived) { jobInfo->timeDelta =3D timeReceived - jobInfo->sent; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index aacc23663e..52007db2ba 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -290,13 +290,10 @@ virStorageBackendGlusterRefreshVol(virStorageBackendG= lusterState *state, if (meta->capacity) vol->target.capacity =3D meta->capacity; if (meta->encryption) { - vol->target.encryption =3D meta->encryption; - meta->encryption =3D NULL; + vol->target.encryption =3D g_steal_pointer(&meta->encryption); } - vol->target.features =3D meta->features; - meta->features =3D NULL; - vol->target.compat =3D meta->compat; - meta->compat =3D NULL; + vol->target.features =3D g_steal_pointer(&meta->features); + vol->target.compat =3D g_steal_pointer(&meta->compat); =20 *volptr =3D g_steal_pointer(&vol); ret =3D 0; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index a680f14afc..f88d225e96 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3443,8 +3443,7 @@ storageBackendProbeTarget(virStorageSource *target, =20 target->backingStore =3D virStorageSourceNew(); target->backingStore->type =3D VIR_STORAGE_TYPE_NETWORK; - target->backingStore->path =3D meta->backingStoreRaw; - meta->backingStoreRaw =3D NULL; + target->backingStore->path =3D g_steal_pointer(&meta->backingS= toreRaw); target->backingStore->format =3D VIR_STORAGE_FILE_RAW; } =20 @@ -3479,8 +3478,7 @@ storageBackendProbeTarget(virStorageSource *target, if (meta->encryption->payload_offset !=3D -1) target->capacity -=3D meta->encryption->payload_offset * 512; =20 - *encryption =3D meta->encryption; - meta->encryption =3D NULL; + *encryption =3D g_steal_pointer(&meta->encryption); =20 /* XXX ideally we'd fill in secret UUID here * but we cannot guarantee 'conn' is non-NULL diff --git a/src/util/virfile.c b/src/util/virfile.c index d6faf7e3d2..2d9c89ebbe 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -967,8 +967,7 @@ int virFileNBDDeviceAssociate(const char *file, =20 VIR_DEBUG("Associated NBD device %s with file %s and format %s", nbddev, file, fmtstr); - *dev =3D nbddev; - nbddev =3D NULL; + *dev =3D g_steal_pointer(&nbddev); =20 return 0; } diff --git a/src/util/virlease.c b/src/util/virlease.c index 0e28a47dd2..48b0f6fe57 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -254,7 +254,6 @@ virLeaseNew(virJSONValue **lease_ret, if (virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expir= ytime) < 0) return -1; =20 - *lease_ret =3D lease_new; - lease_new =3D NULL; + *lease_ret =3D g_steal_pointer(&lease_new); return 0; } diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 7c892d6267..2306ab0cb1 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -839,16 +839,13 @@ virNumaGetPages(int node, } while (exchange); =20 if (pages_size) { - *pages_size =3D tmp_size; - tmp_size =3D NULL; + *pages_size =3D g_steal_pointer(&tmp_size); } if (pages_avail) { - *pages_avail =3D tmp_avail; - tmp_avail =3D NULL; + *pages_avail =3D g_steal_pointer(&tmp_avail); } if (pages_free) { - *pages_free =3D tmp_free; - tmp_free =3D NULL; + *pages_free =3D g_steal_pointer(&tmp_free); } *npages =3D ntmp; return 0; --=20 2.34.1