From nobody Sat May 30 16:35:39 2026 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=1778089363; cv=none; d=zohomail.com; s=zohoarc; b=L6O+ebHAOA0xzZcUTI8ccrr/qu1V1aiw6z9vky/H6tf8C5bq7NuyeM3ZDVVmq2XgzxOf8A7ylIJFxeby3U96DAlf9lpFDO3N1Age+qSzYLDE5eZAaS8+OOu+p1DhFgsZ916xoULaPivL5fS3einq4FELtj6mdxJ7T16ZUUvPuR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778089363; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1S+aH3UtjvK7Uf2yjrzsTpi2qAkaThoAY0wsouK4EuA=; b=TjK76QCJAFYfg0BGGkMRUEmnkB+oTT/ffThRM+rAeX5hMCORUuaU5qfGSohgu8lwl26X5YAimai63LixTXE1JrULJ8qdBKWH1lS5vTvlkFzOusHXG0nTdqfiXXz10woxltizse7RIdkfZXi2bKQzbIx1d4AyEKSVCYUFQJ4o3YU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778089363943915.9471230905174; Wed, 6 May 2026 10:42:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKgFx-0006wp-5w; Wed, 06 May 2026 13:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKgFp-0006wJ-4V for qemu-devel@nongnu.org; Wed, 06 May 2026 13:41:50 -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 1wKgFn-0002Q1-Rm for qemu-devel@nongnu.org; Wed, 06 May 2026 13:41:48 -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-640-9RxiR_t_Py6BsXRF1mnYig-1; Wed, 06 May 2026 13:41: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 94FBD1956089; Wed, 6 May 2026 17:41:40 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F01CC19560A2; Wed, 6 May 2026 17:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778089307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1S+aH3UtjvK7Uf2yjrzsTpi2qAkaThoAY0wsouK4EuA=; b=QMWJgxggGjH0I/5dYbHMPXRIH8ALyHdcWuADhjOwZcFusKT9fp0eHqsu4r00/AorRiZgLX I85HT7X71LDlXpaxOUEa7rxt9PpyVbC5E5dlWg9wU//YJGa0yVDxFvyY9/xkXexaR1jgvw D1vi0rK/OID2vTbzTlLEkpa5mCT4dBs= X-MC-Unique: 9RxiR_t_Py6BsXRF1mnYig-1 X-Mimecast-MFC-AGG-ID: 9RxiR_t_Py6BsXRF1mnYig_1778089300 From: Thomas Huth To: Matthew Rosato , Farhan Ali , qemu-s390x@nongnu.org Cc: Eric Farman , Halil Pasic , Christian Borntraeger , Cornelia Huck , qemu-devel@nongnu.org Subject: [PATCH] hw/s390x: Fix memory leaks after removing elements with QTAILQ_REMOVE Date: Wed, 6 May 2026 19:41:35 +0200 Message-ID: <20260506174135.2630613-1-thuth@redhat.com> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.443, 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_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1778089366480154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The elements that get removed with QTAILQ_REMOVE are never referenced afterwards anymore, so the corresponding memory should get freed. Signed-off-by: Thomas Huth Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato Tested-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-vfio.c | 1 + 2 files changed, 2 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 4de7b587e8a..d45e08a69fd 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -911,6 +911,7 @@ static void s390_pcihost_unrealize(DeviceState *dev) while (!QTAILQ_EMPTY(&s->zpci_groups)) { group =3D QTAILQ_FIRST(&s->zpci_groups); QTAILQ_REMOVE(&s->zpci_groups, group, link); + g_free(group); } } =20 diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 7c754b656da..db6de00bd28 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -101,6 +101,7 @@ void s390_pci_end_dma_count(S390pciState *s, S390PCIDMA= Count *cnt) cnt->users--; if (cnt->users =3D=3D 0) { QTAILQ_REMOVE(&s->zpci_dma_limit, cnt, link); + g_free(cnt); } } =20 --=20 2.54.0