Skip to contentSkip to conversation

FAILED: patch "[PATCH] iio: buffer: serialize buffer teardown with mode claims" failed to apply to 6.1-stable tree

PATCH Applied [email protected] 3 participants 3 messages Oct 6 – Oct 7

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 84bb0fc46ccf6a545b8fdf57cda83770186ed8dd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026100642-numerator-hurler-5b19@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 84bb0fc46ccf6a545b8fdf57cda83770186ed8dd Mon Sep 17 00:00:00 2001
From: Jinseob Kim <[email protected]>
Date: Mon, 21 Sep 2026 15:24:21 +0900
Subject: [PATCH] iio: buffer: serialize buffer teardown with mode claims
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Buffer-mode claims hold mlock to guarantee that the device remains in buffer mode until the claim is released. Normal buffer updates take info_exist_lock followed by mlock in iio_update_buffers().

However, iio_device_unregister() disables and deactivates all buffers without taking mlock. This can invalidate buffer state, including active_scan_mask, while a buffer-mode claim is held.

Take mlock in iio_disable_all_buffers() so that unregister honors the mode-claim lifetime guarantee. The info_exist_lock -> mlock ordering matches iio_update_buffers().

Fixes 0a8565425afd ("iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs")
drivers/iio/industrialio-buffer.c +4 -0
index 902401be0b67..4294101810fd 100644
@@ -1377,6 +1377,10 @@ EXPORT_SYMBOL_GPL(iio_update_buffers);
 
 void iio_disable_all_buffers(struct iio_dev *indio_dev)
 {
+	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+
+	guard(mutex)(&iio_dev_opaque->mlock);
+
 	iio_disable_buffers(indio_dev);
 	iio_buffer_deactivate_all(indio_dev);
 }
#1 lore raw

PATCH 1/1 iio: buffer: serialize buffer teardown with mode claims

commit 84bb0fc46ccf6a545b8fdf57cda83770186ed8dd upstream.

Buffer-mode claims hold mlock to guarantee that the device remains in buffer mode until the claim is released. Normal buffer updates take info_exist_lock followed by mlock in iio_update_buffers().

However, iio_device_unregister() disables and deactivates all buffers without taking mlock. This can invalidate buffer state, including active_scan_mask, while a buffer-mode claim is held.

Take mlock in iio_disable_all_buffers() so that unregister honors the mode-claim lifetime guarantee. The info_exist_lock -> mlock ordering matches iio_update_buffers().

Fixes 0a8565425afd ("iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs")

[ Backport by Jinseob Kim to 6.1.y: mlock is still in struct iio_dev,
so use indio_dev->mlock instead of iio_dev_opaque->mlock. ]

---
 drivers/iio/industrialio-buffer.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/industrialio-buffer.c +2 -0
index d0bcb9c57f96..06b5e9fb9b43 100644
@@ -1291,6 +1291,8 @@ EXPORT_SYMBOL_GPL(iio_update_buffers);
 
 void iio_disable_all_buffers(struct iio_dev *indio_dev)
 {
+	guard(mutex)(&indio_dev->mlock);
+
 	iio_disable_buffers(indio_dev);
 	iio_buffer_deactivate_all(indio_dev);
 }
maintainer Applied
#2 lore raw

Re: [PATCH 6.1.y] iio: buffer: serialize buffer teardown with mode claims

Quoted 2 lines

Take mlock in iio_disable_all_buffers() so that unregister honors the mode-claim lifetime guarantee.

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha