From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 650AF3B531D; Sat, 17 Oct 2026 17:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256777; cv=none; b=gr/BWjFemIoIRnA8i2Ot+MjvfI9Nrw83G96ntelbcBgvEig438W+8nHCGBq4dmgq/JDt8REBdShngpl2PRpmTwOxX1GuEsQdWQ6QI/Nsf6Dlqxqn0nGJ5D4pr1GUYrR55GrNfU3vNt5II56gpm25QEVT7Jazku/nism8pMURj4Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256777; c=relaxed/simple; bh=LN6INRhrUomVd4TbYgK2h0qBxQIhTZTrUsgsnrl4vQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gidLyLATlseqhVNPxFMbxMmghVU/JOlmbGEksKtCUZs0+/DrWt2L5HrNaX58nctemSeGuiWYVNNMVT2Rs7H4Ges2UQoTD2WeOq4lnmA3UDQL8Uh6ogey3KA+qwcXPPLfiI0aTtaii7DYViMGSFef88F99OcaMSqV5/loYBro1lY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pBHcZtvS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pBHcZtvS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB97C1F000C4; Sat, 17 Oct 2026 17:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792256776; bh=on547HeCXuskO0KPZ07kJezfGUOsPxswSLTofcJHQEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pBHcZtvSbOkRDnVQhp7yRhP3PT2+53O5rmIhDxsSh9HFHgzd1SvFEayD7v33IPqmC VmGUuNhcRy5X24fbXMVX7pGAj0E4xA0tAApZAZ74gnt1argNE8K1knZIN9wfrlnLz7 eMBsHbCVjCYspe+HfdvDgD06itOJDKZOwEQ6/9iA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Cameron , Jinseob Kim , Joshua Crofts , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron Subject: [PATCH 6.6 0341/1674] iio: buffer: serialize buffer teardown with mode claims Date: Sat, 17 Oct 2026 17:43:33 +0200 Message-ID: <20261017160439.879117265@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jinseob Kim 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") Suggested-by: Jonathan Cameron Signed-off-by: Jinseob Kim Reviewed-by: Joshua Crofts Reviewed-by: Nuno Sá Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/industrialio-buffer.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1294,6 +1294,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); }