From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935531; cv=none; d=zohomail.com; s=zohoarc; b=CJgr82EwjSTaM9euSiKEsOGtk2Inb5PLxrhiKBIEilvhh0cx11kTgHSShxfIghyojqoGMzzYlB+hunRjY2MEyoSpYpGhIlvhX9xokJwwQP9V7iIql6SQaVpbR1olf2RuN8bFaf+GBn7S3kYNaiiPT+Sx+4XBHK2kpDECjOZLYW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935531; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1f+PWZIz/I4CGg2ZXncwhIizsYznxLtF7pmbIdxCI7M=; b=dPaXztrtSaEtmEmHMsX9DkAs8PpU2vyl8p9bCWP3s8jL66whILCuebpVGAe5FZV+ISxR+cMki7bCn26FwSFDOC6KJDKOiHzTDqby7t071PSTTEAaMcH5SSpQHGUcJ7TTI26IHQliX/5tOKgBjr3zF7js5qTfblV+aLlkjjiZ6cA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745935531123892.7648419915743; Tue, 29 Apr 2025 07:05:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9lZn-0001Ly-Sn; Tue, 29 Apr 2025 10:04:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZj-0001Jp-T8 for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZg-0005ay-8r for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:43 -0400 Received: from mx-prod-mc-02.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-240-pnVa7Cf5OiGQkPg5KRI89w-1; Tue, 29 Apr 2025 10:03:20 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64E1819560B9; Tue, 29 Apr 2025 14:03:17 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0351F19560A3; Tue, 29 Apr 2025 14:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935479; 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=1f+PWZIz/I4CGg2ZXncwhIizsYznxLtF7pmbIdxCI7M=; b=KNmBIpkGEPCCAfv0+SwbdvG1cjrN10uJLWL0uOT09QS6LqkintUwixM2OU7KIET+95J9qC Uz+WJfEnubPuU0R8Xg5WbBBnuK5mi7F5VHxz6fGq1p55UQDDGfOuHB7EmOwhQlraMaBOBd 0fPlKuG/j0dBnT2FlMoGtCUWRDD44pI= X-MC-Unique: pnVa7Cf5OiGQkPg5KRI89w-1 X-Mimecast-MFC-AGG-ID: pnVa7Cf5OiGQkPg5KRI89w_1745935397 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 1/6] qdev: make release_string() idempotent Date: Tue, 29 Apr 2025 18:03:01 +0400 Message-ID: <20250429140306.190384-2-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935533743019100 From: Marc-Andr=C3=A9 Lureau So it can eventually be called multiple times safely. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/core/qdev-properties.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 147b3ffd16..bad111833c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -484,7 +484,8 @@ const PropertyInfo qdev_prop_usize =3D { static void release_string(Object *obj, const char *name, void *opaque) { const Property *prop =3D opaque; - g_free(*(char **)object_field_prop_ptr(obj, prop)); + + g_clear_pointer((char **)object_field_prop_ptr(obj, prop), g_free); } =20 static void get_string(Object *obj, Visitor *v, const char *name, --=20 2.49.0 From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935576; cv=none; d=zohomail.com; s=zohoarc; b=bTrsTtM7Kc9zKpgQGsFdOYZnrBE31gG4s+UAL35Eyby/HdR/IIwMNAR/r3F39UUUIzvACqR3sSx1Wwa4DgYEzf/UPAiKIHtNIueiILbh6+BYa7H8dVBuCj+11NeriFWlwfXvwgr6TN0GP1RckJV1a9mETMejKabpPAPdCG5fO8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935576; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ElO/ngycnV01KSHZ2Wn33oP4orMzW8dezzCCc8O9yIc=; b=KHQVg3/mIX3rPOwh2WkHoN+ubIR7yoitxkcZO2BvcwJu9b0cZSFOieDcRs9JF/ZDziff1tdkV373qj1/QHwIskIdBSklawIM0eJaZ1R2ZDLfkRPXtjExPFgjVl+2LPQGVxB/xVD8o70HLO/ATcXBqtyG/djmBfb5sjk+vf2c/h8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745935576682543.5783376094159; Tue, 29 Apr 2025 07:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9lZg-0001Gg-1s; Tue, 29 Apr 2025 10:04:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZc-0001Ey-7b for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZa-0005Zx-K2 for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:35 -0400 Received: from mx-prod-mc-02.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-558-LqvBAay1MsuYgld8kADXKQ-1; Tue, 29 Apr 2025 10:03:24 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6CC119560A2; Tue, 29 Apr 2025 14:03:22 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A25D01800378; Tue, 29 Apr 2025 14:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935473; 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=ElO/ngycnV01KSHZ2Wn33oP4orMzW8dezzCCc8O9yIc=; b=GIQOxzEqXh0PXCKi7192ENs7oQoDw3gPXnc/xEgcxzFGZL3vS7xvdv4UynfRa27cB6jXbZ 4jtitkS07TSoW+ufsRDW4AW0a0C3F5ncgDHYrNeY9tuZtHpsPlHmn7Z7lUC5KugOon5SyU OaRnqY6EJgekYxRVK30UrXik1y7PXzc= X-MC-Unique: LqvBAay1MsuYgld8kADXKQ-1 X-Mimecast-MFC-AGG-ID: LqvBAay1MsuYgld8kADXKQ_1745935403 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 2/6] qdev: make release_drive() idempotent Date: Tue, 29 Apr 2025 18:03:02 +0400 Message-ID: <20250429140306.190384-3-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935578917019000 From: Marc-Andr=C3=A9 Lureau So it can eventually be called multiple times safely. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/core/qdev-properties-system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 8e11e6388b..b10835185c 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -231,6 +231,7 @@ static void release_drive(Object *obj, const char *name= , void *opaque) if (*ptr) { blockdev_auto_del(*ptr); blk_detach_dev(*ptr, dev); + *ptr =3D NULL; } } =20 --=20 2.49.0 From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935573; cv=none; d=zohomail.com; s=zohoarc; b=jG8+WmzxYtbusWBOj0PgwWxnVvzk1FHsyJcwwFXO7lVY62tiG07EUV450kBILT4dDrJdf5iAj2LlFcySKXPKc9tc5zg2HPV2VIfKyiVPrXb3Pbh8j5rbm+oOpV6Vvm2EYFnxjOFq3K4ujzlse9iVZyBIME40qBDM52uHkkCQ0DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935573; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3RD+T3s3ZLoFw7FsAGFcWoNvnyVuBj6hHjHenRueXpE=; b=EWoaWS6SrEku2alxVjACOr/5uU2qB1HXT0tB7Kz5NLIzsAoxgKzMS2WFrTR82UCuRxvLLFic4vkw7Z8i+G2lgoQOEIl4DYdDmM1NYu+NwgxKt9YQN9AeqaDx/ycDXVVK4xdgGnfMrpIauwnBxHzZTO0EB60WGjR/R7DfZXEZ3b8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745935573960670.7553973418426; Tue, 29 Apr 2025 07:06:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9lZx-0001XA-Cu; Tue, 29 Apr 2025 10:04:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZj-0001Jq-Tm for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZg-0005aw-A2 for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:43 -0400 Received: from mx-prod-mc-03.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-442-8LpxaMOtMiOa2gDBrpyNXA-1; Tue, 29 Apr 2025 10:03:30 -0400 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF20F1955DDA; Tue, 29 Apr 2025 14:03:28 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FB8E18001D5; Tue, 29 Apr 2025 14:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935479; 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=3RD+T3s3ZLoFw7FsAGFcWoNvnyVuBj6hHjHenRueXpE=; b=X6lhLnZFuIOhyU0Q5YcGNrj1leHMHTAv/yStmXUoUkrqVx0xWgeU0uI3TOPw1pYM39b3oM m6i3ROzuFbjuW/2oGqOLBXoxDO0ssaKtxVor+RfEMyv1UZX4mW4Ho4bVAEQ1bOm9lMCDep Yj8ptFqKYIxcXDOA1iEUZfRCd/qlsDw= X-MC-Unique: 8LpxaMOtMiOa2gDBrpyNXA-1 X-Mimecast-MFC-AGG-ID: 8LpxaMOtMiOa2gDBrpyNXA_1745935409 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 3/6] qdev: make release_tpm() idempotent Date: Tue, 29 Apr 2025 18:03:03 +0400 Message-ID: <20250429140306.190384-4-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935574878019000 From: Marc-Andr=C3=A9 Lureau So it can eventually be called multiple times safely. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- backends/tpm/tpm_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c index f2d1739e33..16eab82cd2 100644 --- a/backends/tpm/tpm_util.c +++ b/backends/tpm/tpm_util.c @@ -72,6 +72,7 @@ static void release_tpm(Object *obj, const char *name, vo= id *opaque) =20 if (*be) { tpm_backend_reset(*be); + *be =3D NULL; } } =20 --=20 2.49.0 From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935587; cv=none; d=zohomail.com; s=zohoarc; b=JsI1lapxKINj0nJY9zqtl5M6x31rzXtDqvVPlihBaI2Au6hQdTGkYpUqu196QSv+Y/dNRrVGYXW3I28dqEvxgc9w9tynoztb6xppTkQv17Pks8di6DnwqDW4plxMcgH7Dc4zJJVnsnHQwjGhXAJS3oJZsXZAi38At3lCcX4RF6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935587; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bb/H9vVU1cMZ8hb7U4a6OciQYW7eZ95HeN92fvbr3X0=; b=gaszUV/urWjoLAZrCK5O4FH0Qwwe+bQNHNAuWvvzbHL8TBSmcDdtpUYgfP2kmiNOv2Q4VL3OS/b7V5aTyDQ9ziQrYH+uneqb7xVN1YsFHVX6bIYHLM6HjrwQEC7cPZlfycYE3AJsjIfJFMINGvZ3xIrhyyM4UB+cBKTK6jNXP2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745935587601454.463665121943; Tue, 29 Apr 2025 07:06:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9laX-0002sa-CC; Tue, 29 Apr 2025 10:05:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9laM-0002h5-8Y for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:05:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9laJ-0005s0-AX for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:05:21 -0400 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-519-97zJwr8fPe-BKcVtUuDZbw-1; Tue, 29 Apr 2025 10:04:05 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 99B19180099C; Tue, 29 Apr 2025 14:03:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 36E67180045C; Tue, 29 Apr 2025 14:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935518; 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=bb/H9vVU1cMZ8hb7U4a6OciQYW7eZ95HeN92fvbr3X0=; b=Twm9Wx+Zh6CnraRuKYiPvEu517Rwzw3uVEfHd5+uotYMEmt+YUWWIxKU2yPE0j1x2x734k O1cuOXy/6taAds3lSUzC9nJYYGkPInZcH3hm7b1OgUN7U81ShiM7J2lcQKfo8LRLv473JA I2UxbspwQp5k2ne5Vyowh5t2FPgTn8M= X-MC-Unique: 97zJwr8fPe-BKcVtUuDZbw-1 X-Mimecast-MFC-AGG-ID: 97zJwr8fPe-BKcVtUuDZbw_1745935427 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 4/6] qdev: make release_prop_array() free array and idempotent Date: Tue, 29 Apr 2025 18:03:04 +0400 Message-ID: <20250429140306.190384-5-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935589485019100 From: Marc-Andr=C3=A9 Lureau Fix a memory leak, and allow it to be called multiple times safely. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/core/qdev-properties.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index bad111833c..7a53c85887 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -620,15 +620,16 @@ static void release_prop_array(Object *obj, const cha= r *name, void *opaque) char *elem =3D *arrayptr; int i; =20 - if (!prop->arrayinfo->release) { - return; + if (prop->arrayinfo->release) { + for (i =3D 0; i < *alenptr; i++) { + Property elem_prop =3D array_elem_prop(obj, prop, name, elem); + prop->arrayinfo->release(obj, NULL, &elem_prop); + elem +=3D prop->arrayfieldsize; + } } =20 - for (i =3D 0; i < *alenptr; i++) { - Property elem_prop =3D array_elem_prop(obj, prop, name, elem); - prop->arrayinfo->release(obj, NULL, &elem_prop); - elem +=3D prop->arrayfieldsize; - } + *alenptr =3D 0; + g_clear_pointer(arrayptr, g_free); } =20 /* --=20 2.49.0 From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935551; cv=none; d=zohomail.com; s=zohoarc; b=Z8qJA05GfUoGdnHJQnLJsG7coCqW/uS+Ghfc5wU/JIRebCjRoa1EVN+jXn3+8/nyuJXZLS/crynmU427bj4JAy7q2lgTsTvq3bKwwVkppUNyVwg4Mpyan/LNO9uZ5eUSUpmBbSDs/eMN72CA88GCOOmGn93SVwoxAvD7Oc+UztA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935551; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GrX2PGOCQfJNebdLuXYlBWMYGYH3MoivSKFh1V2a14k=; b=CoyRJUmVxiQc77+ImW7BigGiTIL1Qliyu5Ixd6POoDUXnOr9Kbus9Oqq6h1/gVmPW86ohlHZpJuj+zCDcWX7fr72cX06n+lD3cc3LcxPikU8O8w1NtBunel2IsbCy/86pqDqFV3DFj28VTHppuib8uJUCW109ePnkWvEEwVCSzs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174593555129335.04667017510474; Tue, 29 Apr 2025 07:05:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9la9-0002DZ-Q1; Tue, 29 Apr 2025 10:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZw-0001Wx-Vs for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZv-0005dU-7O for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:56 -0400 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-623-qAKlQEOfM3SpJai0tj8i4Q-1; Tue, 29 Apr 2025 10:03:42 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 29C511956095; Tue, 29 Apr 2025 14:03:41 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD10819560A3; Tue, 29 Apr 2025 14:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935494; 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=GrX2PGOCQfJNebdLuXYlBWMYGYH3MoivSKFh1V2a14k=; b=UFW318C8GIqv82ipxDNBcGVplzI+adF3+WGVMMtquU0Y39kWUSVPkkuWM7GU05lyTlOcfE cdbCqjyfENjjVBK0uzGwDO5CleZeIseo6er/4XcxQrer4TViHFTHUmqXCI0Hq3nojyBJsA MWakOYR6AbTQZWxVtcu+YQodq30VmTA= X-MC-Unique: qAKlQEOfM3SpJai0tj8i4Q-1 X-Mimecast-MFC-AGG-ID: qAKlQEOfM3SpJai0tj8i4Q_1745935421 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 5/6] tests: add /qdev/free-properties test Date: Tue, 29 Apr 2025 18:03:05 +0400 Message-ID: <20250429140306.190384-6-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935553715019100 From: Marc-Andr=C3=A9 Lureau Add a simple qdev test to check that allocated properties get free with the object. This test exhibited array leaks before the fixes. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- tests/unit/test-qdev.c | 96 ++++++++++++++++++++++++++++++++++++++++++ tests/unit/meson.build | 1 + 2 files changed, 97 insertions(+) create mode 100644 tests/unit/test-qdev.c diff --git a/tests/unit/test-qdev.c b/tests/unit/test-qdev.c new file mode 100644 index 0000000000..2b4c9dd643 --- /dev/null +++ b/tests/unit/test-qdev.c @@ -0,0 +1,96 @@ +#include "qemu/osdep.h" + +#include "hw/qdev-properties.h" +#include "qom/object.h" +#include "qapi/error.h" +#include "qapi/visitor.h" + + +#define TYPE_MY_DEV "my-dev" +typedef struct MyDev MyDev; +DECLARE_INSTANCE_CHECKER(MyDev, STATIC_TYPE, + TYPE_MY_DEV) + +struct MyDev { + DeviceState parent_obj; + + uint32_t prop_u32; + char *prop_string; + uint32_t *prop_array_u32; + uint32_t prop_array_u32_nb; +}; + +static const Property my_dev_props[] =3D { + DEFINE_PROP_UINT32("u32", MyDev, prop_u32, 100), + DEFINE_PROP_STRING("string", MyDev, prop_string), + DEFINE_PROP_ARRAY("array-u32", MyDev, prop_array_u32_nb, prop_array_u3= 2, qdev_prop_uint32, uint32_t), +}; + +static void my_dev_class_init(ObjectClass *oc, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + dc->realize =3D NULL; + device_class_set_props(dc, my_dev_props); +} + +static const TypeInfo my_dev_type_info =3D { + .name =3D TYPE_MY_DEV, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(MyDev), + .class_init =3D my_dev_class_init, +}; + +/* + * Initialize a fake machine, being prepared for future tests. + * + * Realization of anonymous qdev (with no parent object) requires both + * the machine object and its "unattached" container to be at least presen= t. + */ +static void test_init_machine(void) +{ + /* This is a fake machine - it doesn't need to be a machine object */ + Object *machine =3D object_property_add_new_container( + object_get_root(), "machine"); + + /* This container must exist for anonymous qdevs to realize() */ + object_property_add_new_container(machine, "unattached"); +} + +static void test_qdev_free_properties(void) +{ + MyDev *mt; + + mt =3D STATIC_TYPE(object_new(TYPE_MY_DEV)); + object_set_props(OBJECT(mt), &error_fatal, + "string", "something", + "array-u32", "12,13", + NULL); + qdev_realize(DEVICE(mt), NULL, &error_fatal); + + g_assert_cmpuint(mt->prop_u32, =3D=3D, 100); + g_assert_cmpstr(mt->prop_string, =3D=3D, "something"); + g_assert_cmpuint(mt->prop_array_u32_nb, =3D=3D, 2); + g_assert_cmpuint(mt->prop_array_u32[0], =3D=3D, 12); + g_assert_cmpuint(mt->prop_array_u32[1], =3D=3D, 13); + + object_unparent(OBJECT(mt)); + object_unref(mt); +} + + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + module_call_init(MODULE_INIT_QOM); + type_register_static(&my_dev_type_info); + test_init_machine(); + + g_test_add_func("/qdev/free-properties", + test_qdev_free_properties); + + g_test_run(); + + return 0; +} diff --git a/tests/unit/meson.build b/tests/unit/meson.build index d5248ae51d..99f59f4ceb 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -159,6 +159,7 @@ if have_system 'test-qdev-global-props': [qom, hwcore] } endif + tests +=3D {'test-qdev': [qom, hwcore]} endif =20 if have_ga and host_os =3D=3D 'linux' --=20 2.49.0 From nobody Sat Nov 15 22:27:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745935589; cv=none; d=zohomail.com; s=zohoarc; b=mJzGPXtLL9YKtQ0v6kHLPiUhOYWXRZL+ucmZ1DFSJwPNAO7oc5x9nVno7raBfq7algTROGQxjYSDKQZC3ZjreG6LehmH/VHoJujuWb8l7f1CQQZGvoQoxLLkUjGB0/IU1ZbsIpYJA/bAmBdY7/mWa5aUDKAISxmNzAP6n9wVBFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745935589; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uLtoowsYeTkKZJ4mHa9vOQu041jpGafZweYxc7y8CFU=; b=mO/GqhXwxyejr0fxtneKhZXq3v8J0AWdxJffW0skirhI54lgxt2Zo+1fmoFEmo/GM4a5ddATl82CguT6z11f2ZC7ePE0dkcwzbPcDL9st2zrlgkH2j7s8xHgTrZGIFwRU2popWiR+lVeDpuWxa2qsuLN7UZcBnj4CX0i2ClRfNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745935589694129.8093213557505; Tue, 29 Apr 2025 07:06:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9la7-0001ld-3b; Tue, 29 Apr 2025 10:05:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZw-0001Wv-Qz for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9lZv-0005dS-0b for qemu-devel@nongnu.org; Tue, 29 Apr 2025 10:04:56 -0400 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-550-jOtU4fwLNYqqlQn8xf-nLA-1; Tue, 29 Apr 2025 10:03:47 -0400 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 C26ED1800986; Tue, 29 Apr 2025 14:03:46 +0000 (UTC) Received: from localhost (unknown [10.45.242.19]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6738018001DA; Tue, 29 Apr 2025 14:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745935494; 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=uLtoowsYeTkKZJ4mHa9vOQu041jpGafZweYxc7y8CFU=; b=TdI0Y1eUAt1TCI3JH6g+So1iJNMLNyIfmc8apPWEbUZEbUPbEbEHXiQksgGtsGvPT5cl5X lxsoJW/CVMZcT+bMWnQHjs++QbbKINZlVCZv1vaapChRq8a5nTuoNh+3tNX/CzZIgrlte0 OqCtElzPkg+Ci1OhomCKj6Uz9grQvOw= X-MC-Unique: jOtU4fwLNYqqlQn8xf-nLA-1 X-Mimecast-MFC-AGG-ID: jOtU4fwLNYqqlQn8xf-nLA_1745935427 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Stefan Berger , Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 6/6] RFC: qom/object: simplify object_property_del_all() Date: Tue, 29 Apr 2025 18:03:06 +0400 Message-ID: <20250429140306.190384-7-marcandre.lureau@redhat.com> In-Reply-To: <20250429140306.190384-1-marcandre.lureau@redhat.com> References: <20250429140306.190384-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.489, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745935591493019100 From: Marc-Andr=C3=A9 Lureau Since commit 9859fac ("object: release all props"), the code was changed to tracks the already released properties in a hash table. I am not sure why this was done, perhaps to prevent from potential crashes if properties are being added dynamically during release. I am not sure if it's a valid concern though. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qom/object.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/qom/object.c b/qom/object.c index 664f0f24ae..a2ccebca6d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -656,21 +656,13 @@ static void object_property_del_all(Object *obj) g_autoptr(GHashTable) done =3D g_hash_table_new(NULL, NULL); ObjectProperty *prop; ObjectPropertyIterator iter; - bool released; =20 - do { - released =3D false; - object_property_iter_init(&iter, obj); - while ((prop =3D object_property_iter_next(&iter)) !=3D NULL) { - if (g_hash_table_add(done, prop)) { - if (prop->release) { - prop->release(obj, prop->name, prop->opaque); - released =3D true; - break; - } - } + object_property_iter_init(&iter, obj); + while ((prop =3D object_property_iter_next(&iter)) !=3D NULL) { + if (prop->release) { + prop->release(obj, prop->name, prop->opaque); } - } while (released); + } =20 g_hash_table_unref(obj->properties); } --=20 2.49.0