From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206399; b=l4ZVCU0SiIcxvSDYVf93kGaoPMT5tz2pvnXmvi+YuFp1aVCnjtruaTanc8GUgTboeNnw kXhfJK9q1RbkLecL2M4wvByIFzIUhpr6vh1Ju4/IffK6VR/4k1MtiVs791ZUB56+wB2cy tvH9/cDBfbZL6bZO8x7yR2rkqmLqxMB2SXnXeFz3nDnH9aP511lmfSiCIr6kZWrmsL2iD dcOvnJIY0kkYqPWD3rNWsytkVbieiwIIj8G1+Zyn4YlR4bXFyZszn3QUAbqMPuVvPNjgs rmzpc6sp8eMLERG+cg00lSEAfMn31u5vaIRbyH8XOM7Kok/WT2lHS3Z2dXbJBaj7ahA== 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=MYl2ekGgopZmwR7VTiL8TyluTzIDTffkpL6Q8I5MH+hcTH1ddliGN4YCg5kw8YObHu4J euF6lJhZFTDQ5hijFRZzsU3IywG4Tm839WeHwVbciFp8LeEeH8uOL3yb9E6eExnmEkOkT ehqWznk+KmY5RCkOT+P4HMWACKGsX07iO+C7z9vE6vj85Zn6weZBwLUkRKSEMUSJRkDZx t4L4Lgx21PPwgJdqKlU1QcMobbUxi7Y4HxGRw/jZkEaiBTWtxCEo/jf+I1oeFvnHO3nbw ab4p0AL3OxKppwFhR7mucBl4jMV1UvkcHyTC3HEDfYyqsAbKYLRlBhLWFe1alHiyUiA== 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.51 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 F070C606A31A for ; Wed, 2 Dec 2026 10:13:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F070C606A31A 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-f51.google.com with SMTP id 98e67ed59e1d1-3b41188c8b9so8229440a91.0 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=HuPaolOXTGnzrvh+iffbdI0c3g251aGOJtx9n+iIk3h1QOsLGgDItd8511CNufVtFo Tz0i0PsDFpiOc/Y98Iu3Df315GYAM9wk2dAIhCgZ1yDvKGwjbS7cxt9JguFtARCOKWKE FFG9vcq7MI8it9xl8epGnh0odTzfdYONwLp0cZwNvdBt9lEvZbl7VrGgJGBL/C5Nx92L SPGI9k5bJE7oOHSGztxKwJ3YB8ROITX16VPFYi5lVrexmcOw0oXUGVG4O1mqXYMi90YM e9Xztuk4Px2crCcgemczz14ncwEvKomZd7ztpOoxw84HEqq0n31rJSgcGNUiayl/qhAK hZmQ== X-Forwarded-Encrypted: i=1; AL+hErEwUpJI2BGuLj/fZXLrvSS1n/akLPlHXRgVjxlm3CONt26u18TgyAdKDWksRX4d78LMESHmpXpOFKc=@vger.kernel.org X-Gm-Message-State: APuU4Z8sFZvyq3xoi0/8xiIMGy8Ws+YRFjXg5x3b4wnSMAu1XPcxriqE /4H2rRD+Wq3Pvdu8PwrZL34dmz85y3xJtQbfrwz/oLY26nNcHDNzbQ0h X-Gm-Gg: AZFdTZc31LLxVu1m3j/Xmqv+iyOUobqTEUvyrf7+LWQKSr1zcWqXK7IHvf/CghVyd5I zJXOty1UM+mbrJJj6hD59u8kfVBkGmH1SiVZNZoXXo7O7yHJ+uV8SO559tWEL0bViotnNo4Xa1M 21WI2U7yCz6CONnGi8j0w8zWn/4qFXoMFsDYwUpyd6NOK+mzto6t1iL8Xs5aeCM97L+hP16cgpU JeBZrEuWKsaWMe4UP9idj5tAB4w4q5Pc6RviEUkJ8obqIdV6tbk6h5vXgf0cOa30HhqzJ+a8JDU k+3mS8iAwuw5TaBqaMobYPKQecxUtJ2KhpGQtO+4h9IzvA/UlVqDLT0RulzSRSTANOezNLtK2c8 H4h+1RuRs1/Eyq10Ofx0erCLC6pfyCSJOeHcVLlYDA7fqQ7D0OuynXi4z9FdQuTsOIYf1raKixl eVrO3S+rU55DuG9z2qzjp0ZHEoeFSRfnGq8UfVvtNI724cOAfVktVSkfW8PRGPLxDrQZXtbMrT4 0T7BbiU0xLmIauqvsUjyTtSrqxKdgiqItO4bHPrHXq68H0bfgJASc8Xn3SjvRrkUq14ZCwSmL9w kQdLq+6sx2OsLSwN+m711UWV9y0BNZ1R6Acz7fpKQGNI0VXgPqvUvPO+XaPMlGudgXU/CSfXobw qtYsYBBA= 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-iio@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