From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.196 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035497; b=uNyd9GRckgj16cBLilJZVxQx0Q6GtXVUXAOJ/G+Vfs3RJdfvea2xkEPmiNdfJeGxeWgO SFRCVnP3wd4hOhQIUSVd0quNx7Hsq4UgoY04HAJPzQJwMzclAMoyMKFlM2XkUauJZnO+a 9LaUVhMLfEOq4y+Xtts6oKhoMSyapwCPLppQx3Tlo4ZD/8sn4NjCU92dXvOifL89xhW8F hEHZsT2z1CLyglYtW4bq0Gn4002Thi191QaWwEn0ctlJXayeiC1MWyuKv9EEkyS9Kowv0 WpBMvJqxwHCLGfrndKekIRI75HGgY9ZvogRgj6QueecZwv0I6U64Z6u7JfOmJKnefHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035497; h=DMARC-Filter:X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=P2psOKgkFpP7XxMkjn79XJbXtaxNSRLkzXqfe9lyUBU=; b=o6wOBMqhyCrJcGMdcye0+2+Yiimy892JGYXhH4QlQTCtV0frZd936QYc51amHMAqF+3I jkhco5IkI7BOHVpCagaPGQspGiJSHIw7/CROKxAMDPIVfQpv1oFi0Eilbx3d8q/r4C8BX 7bslHS8/xnkh0N99NJhO0/C9d8sKV3dHZ9TV5bKK6k90rtHDIWZpAVBjYb+VrLCexKw6F 3y89pah3d5cGINn/a2U/py5oCA2z3g4l0g6XfZzco09nAtVbpDBgwJygdjYJw614EtY71 wgJzVL9u0U33w/JtCBbBW+5m2sTVr5CUg1ws9yKBX8LvAYoDrbLzI2YeIUVsp0JaflA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=kaihong.com; spf=pass smtp.mailfrom=kaihong.com; arc=none smtp.remote-ip=115.124.28.196 Received: from out28-196.mail.aliyun.com (out28-196.mail.aliyun.com [115.124.28.196]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF23F606A32C for ; Mon, 30 Nov 2026 10:44:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF23F606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kaihong.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaihong.com X-Alimail-AntiSpam:AC=CONTINUE;BC=0.06735532|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0070992-0.00296372-0.989937;FP=10280724265169323497|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033068002237;MF=wangxiaolei01@kaihong.com;NM=1;PH=DS;RN=9;RT=9;SR=0;TI=SMTPD_---.kDH3LFI_1796035486; Received: from nj-vm-261.pxvirt.local(mailfrom:wangxiaolei01@kaihong.com fp:SMTPD_---.kDH3LFI_1796035486 cluster:ay29) by smtp.aliyun-inc.com; Mon, 30 Nov 2026 18:44:47 +0800 From: Xiaolei Wang To: tglx@kernel.org, radu@rendec.net, briannorris@chromium.org, linux@roeck-us.net, davidgow@google.com, wangxiaolei01@kaihong.com Cc: linux-kernel@vger.kernel.org, geert@linux-m68k.org, kunit-dev@googlegroups.com Subject: [PATCH] genirq/test: Release fake irq descriptors after KUnit tests Date: Mon, 30 Nov 2026 10:44:26 +0000 Message-Id: <20261130104426.1384855-1-wangxiaolei01@kaihong.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Each of the four irq_test_cases cases allocates a virtual interrupt via irq_domain_alloc_descs() in irq_test_setup_fake_irq(), but only calls free_irq() at the end. free_irq() releases the irqaction, not the descriptor, so every run of the suite leaves 4 fake irq descriptors behind. Each leaked descriptor keeps its debugfs node alive at /sys/kernel/debug/irq/irqs/ ("chip: fake"), and the nodes accumulate across repeated runs. kmemleak does not report this because irq descriptors have a kobject/rcu lifetime, but the descriptors are never returned to the irq_desc radix tree and the debugfs entries are never removed. Register a cleanup callback with kunit_add_action_or_reset() immediately after the descriptor is allocated. On test exit, including an early abort on a failed assertion, it frees any still-registered action and then calls irq_free_descs() to release the descriptor. The _or_reset() variant also cleans up when registering the action itself fails. Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts") Signed-off-by: Xiaolei Wang --- kernel/irq/irq_test.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c index e2d31914b3c4..283fe32bf39a 100644 --- a/kernel/irq/irq_test.c +++ b/kernel/irq/irq_test.c @@ -41,14 +41,29 @@ static struct irq_chip fake_irq_chip = { .flags = IRQCHIP_SKIP_SET_WAKE, }; +static void irq_test_free_fake_irq(void *data) +{ + unsigned int virq = (unsigned long)data; + struct irq_desc *desc = irq_to_desc(virq); + + if (desc->action) + free_irq(virq, NULL); + + irq_free_descs(virq, 1); +} + static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd) { struct irq_desc *desc; - int virq; + int virq, ret; virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd); KUNIT_ASSERT_GE(test, virq, 0); + ret = kunit_add_action_or_reset(test, irq_test_free_fake_irq, + (void *)(unsigned long)virq); + KUNIT_ASSERT_EQ(test, ret, 0); + irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq); desc = irq_to_desc(virq); -- 2.34.1