From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206399; b=yjH/OPyxeSVyRClTX6v1tdRsi2mbb6SRwSWGODVJKX/vGpnTFpuwfxCGkG0wzVxgiYZt nt4olkhA+LsJBbzM11CmVdLmNE4n+GDIFx3R3tYssJlOeA0dlJj/avPM50BgJXHegA8j9 Vjc6DR8ex5porHFd+e0E7hdlgp6M0UpmzSSjF3IujGIUlRoeAmyDjHwVCFQiq91B6OkOS XrzgqLtSX5eGRU+MuAj0rWnL/AK25Li9GGYs9wpxyvSybq7fF250SHssBIAC2tYsBVqFh SyoGx3Z8iWjV6JQQYOamDxr4i/I9x4r5L3Ey8/7PKG0Q5nqAr1NsJRStuJWvfhk6FkA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796206399; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=XZ0gobkuN4zyTrhpGJU6F17pVln8DtHGTfYOgy+i4Qc=; b=Rhti0FFJ04oQEnW5xhQ6NTdSJnxEVbPBqKHCuBbAsbwD5qGXPvL7Q0Lqm/J+pJciLsE2 gderd7ggxwouGp5cMWaHytvUJs3agO0UD35FctC/7R9Zorj/Qe2GtYE9Ff7ClOYWcNSP+ GNuRe7Rl80irL+CJpJpZaeednE+1+5TG6n6HyxTKtyWv/7WrQDR5IXu1Rd9ZZUjKnTX2m sa+uQCYl6jeF6jauu6DQeYoqYN7/O3ejvRYtu1+PScZJcn6YRW+pCtonis+1dDIprRChc KBhRmm+Jd7XdvSExm0Za0HeSMezmesp5OyMAKJry4RmX9rLyxoc8kjmd2LwwnSXFfyg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=djj95ciZ; arc=none smtp.remote-ip=209.85.216.53 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00489606A322 for ; Wed, 2 Dec 2026 10:13:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 00489606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=djj95ciZ Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-3b402824d07so8161223a91.1 for ; Wed, 02 Dec 2026 02:13:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796206398; x=1796811198; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XZ0gobkuN4zyTrhpGJU6F17pVln8DtHGTfYOgy+i4Qc=; b=djj95ciZSzpX0ALtNZoPrFdk9hW25k0kBjmJDAoaz2ApstGVqV2Idr3GE3uiQCj6Qj HwFOn3K+zWLWP927iaq6nNuNuJg+v/SJpNc8jUWa0Sb08i1VPvUcBv9WyYDVLF3kxNPZ sb7TszLI3vVlTCDAJy/V+c1MoNrnG8aQK+mt89wAjiKvhER+YqKuHwACxGc8XVb3eKb2 MNgjlBkdXdQf/IVrHIpTaqDtND4JpHARk9w+RpgZw3sn7/eNZDZeubsWCznk1I52pT4V 72LXivUnUh+ZClXDLee0iL0SEXpqtp1T5w237RLxVz3jT9BbTq7Pe7i5h3MW4Ohzv5p2 ZSZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796206398; x=1796811198; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XZ0gobkuN4zyTrhpGJU6F17pVln8DtHGTfYOgy+i4Qc=; b=iMnjctyGgyuitBU2zLvaKAuHe6igthV94+A3Sg+jGs83szXxdG+XWHAlldRufTEqnV NvQuq3K60JWtUxrHndMYI1Gxd7340RVUMTIxK0Bsho5+GVBxSWrgvPcaIR2S+4+/Sa5K zMPYGSvGoknGLtPoqn7mDHAc8514yi4XD+ETygzbcBjIo1vEB3cPF7tj1id99HoUQNsm dBs40Bj4LPDWcmkc+VDU3ZxRSu5YoIjcBclvN/C2llvTXhena/roKuGGo7TScL0NcXEK gqRW+YKOb243mq4h4OjwXqK/DejYouEHFOA0+QVnCm6pNgIfea8nTp+uVbipBSl+uJXK SLYg== X-Forwarded-Encrypted: i=1; AL+hErH/+3WS8i3uwB9a1s7yDmgxWtSM9pJQsPmbqWh95DdGQNNfqxBh5/TjYXOG8adKHLuycF+VHJuUgA6joLE=@vger.kernel.org X-Gm-Message-State: APuU4Z9dq2k75OQWt0gQzD3C84gbYJ/S/TVRp2qWaqNOIU6sRIwVX+xY v6qb+b3KIou1eZSN4ewT9IwvQ3AzXqACdWlfMsk20BqniVmaz6FHAOPd X-Gm-Gg: AZFdTZcKMcEYIuz6gz1n8xr2nFH0o2Ti3VHJHfqx1Zm+X5V5u+U8AAo/YaGKnuz3FYr TFCSk/0RkgzQZpcCkNZdO1/C0v6pWvjPjazVCPMKs6F8efXx+64lWI1yDkGTP/AQKj+zELlhxnx +PQJCHLr7o7fiXfF5P/lnsXUXLzzwC1aIYAS7ZjTGpkrn48ggR7eHIWSZWOEphegSDjhULOKeAJ Nmhkze5RKqW8S0iC7HDpGs89aPuEOMLYAL3hMlpPLxca8yyLFGYoFyrEAmfKKWUetqqRKXex3Mt PxDP/NXNGykJE91Kx7R50XYoBjp8rc0sOZMcaCFAnOGWmO4PzzwtfHSAxEIhMaFv0Enjacuc/m1 I4e24Q9HyGhDFzJKxWk6t6s/uGSeXVaF9JTWdpbhB+0fydw68Z4/XfUbptGwWuH4lfHbv67hlnk P/xkogmtP3iN6RsLx4xUrrqH3MDqZQNAGOaKPEeFlKKqEcmYaU6myu632UJn1evjMyzxZYIo0Jq JcuAe0EBRIxtBOBDMWND/R1Ou2CsxlOJdqYunfQdfN6A3vF0zdHPFN3e2WiWeG0m3CbnEIaDlJs k5GxsqRDbGG9i+Cb3FFIfCncCAJeK/Sjjtbl5sRUZ3JfFczb/6RC/bJ3r8C9jrXvyytPmcYwf8j TXKqXWXU= X-Received: by 2002:a17:90a:ec88:b0:3b4:127a:2bb9 with SMTP id 98e67ed59e1d1-3b41c8d9275mr40055223a91.13.1796206397968; Wed, 02 Dec 2026 02:13:17 -0800 (PST) Received: from DESKTOP-TPPBPA1 (36-226-254-86.dynamic-ip.hinet.net. [36.226.254.86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b40a878d50sm65068816a91.11.2026.12.02.02.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 02:13:17 -0800 (PST) From: Lin Tzu Yang To: Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: dummy: free the sw device on configfs release Date: Wed, 2 Dec 2026 18:13:13 +0800 Message-ID: <20261202101313.944902-1-rongh7426@gmail.com> X-Mailer: git-send-email 2.51.1.windows.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 iio_dummy_probe() allocates the struct iio_sw_device that embeds the configfs group of a dummy device, but nothing frees it: iio_dummy_remove() frees the iio_dev only, and iio_dummy_type has no ->release(). Every mkdir/rmdir of a directory under /sys/kernel/config/iio/devices/dummy/ leaks it. Free it from the ->release() callback of the config_item_type, which configfs calls when the last reference to the item is dropped, as commit 8fb20cdf9c86 ("iio: trigger: free hrtimer and loop triggers on configfs release") does for the software triggers. Fixes: 3d85fb6f8104 ("iio: dummy: Convert IIO dummy to configfs") Signed-off-by: Lin Tzu Yang --- Tested in a QEMU/KVM arm64 guest with kmemleak and KASAN, on configfs-next 2e0fad9d2eae, where this file is the same as on fixes-togreg. After 50 mkdir/rmdir pairs of a dummy device, kmemleak reported 29 unreferenced 192-byte objects allocated in iio_dummy_probe() before the patch, and none after. Removing a dummy device while its character device is open still works: reads from the open file fail afterwards, with no KASAN reports. The patch is against fixes-togreg, on top of 8fb20cdf9c86. This patch was written with the help of an AI coding assistant (Claude). I ran the tests above and reviewed the change. drivers/iio/dummy/iio_simple_dummy.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c index 28ae1e7b59..2f3ea3b419 100644 --- a/drivers/iio/dummy/iio_simple_dummy.c +++ b/drivers/iio/dummy/iio_simple_dummy.c @@ -23,7 +23,17 @@ #include #include "iio_simple_dummy.h" +static void iio_dummy_release(struct config_item *item) +{ + kfree(to_iio_sw_device(item)); +} + +static const struct configfs_item_operations iio_dummy_item_ops = { + .release = iio_dummy_release, +}; + static const struct config_item_type iio_dummy_type = { + .ct_item_ops = &iio_dummy_item_ops, .ct_owner = THIS_MODULE, }; -- 2.47.3