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

From: Joshua Crofts

Date: Wed Sep 23 2026 - 03:44:06 EST


On Mon, 21 Sep 2026 15:24:21 +0900
Jinseob Kim <kimjinseob88@xxxxxxxxx> wrote:

> 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")
> Suggested-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> Signed-off-by: Jinseob Kim <kimjinseob88@xxxxxxxxx>
> ---

Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>

--
Kind regards,
Joshua Crofts