From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 873B647F2E5 for ; Fri, 15 May 2026 11:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778845618; cv=none; b=WZwMJeOLxSwM9Kc1GP2+/DR44rauWtRroeTELJ1Tw4ezJGsUJpj1XHwQAlQ9KyZlzjGD/udv3oD9uRBVQwDeboY7f8s4ht+1kXPXygCEYr6y8SGTXVUoKI8Mku1+jPRESLvpZlxtz3PrOccVPWpwWAR/CwtYTDmjAwDmMIXc0eA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778845618; c=relaxed/simple; bh=dB4JQXDnKr8aFczh/YIQFahf68RFikIDud7sfXVdMK4=; h=Subject:To:From:Date:Message-ID:MIME-Version:Content-Type; b=nh72/uJl/WIsFNPESH3sAmfTDXjgtnVHszNbhsPr3HOFs3lgevk6lJOxZz6lhim4k9D2OQDD9qLzBRM6BBQg6F0HNTt6ty5QPY5OY1bec+PUTYXFDO1Mnc+6cJkfDWU1NjP1plF47JLIpSpuMFNaliu/GgIyIvubRzwUIiwQzCw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lLxC/lof; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lLxC/lof" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F25F3C2BCB8; Fri, 15 May 2026 11:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778845618; bh=dB4JQXDnKr8aFczh/YIQFahf68RFikIDud7sfXVdMK4=; h=Subject:To:From:Date:From; b=lLxC/lofj5vNkZ6nNH5lz288Bow5fEQGieeuWul61jhhYw2AFt8eszxEcYjTBcnbZ ouQAjql73889nR2mURheYlCSDD07OJT9M3zZxs826v8pBbxLoxrzFwlu2ZH/96v/5j NHrCf1IutTOqAsWOuOjqmDByGnYS7YpNjD2abOcs= Subject: patch "iio: dac: ad5686: acquire lock when doing powerdown control" added to char-misc-linus To: rodrigo.alencar@analog.com,Stable@vger.kernel.org,jic23@kernel.org From: Date: Fri, 15 May 2026 13:46:01 +0200 Message-ID: <2026051501-cornball-basis-f54e@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit This is a note to let you know that I've just added the patch titled iio: dac: ad5686: acquire lock when doing powerdown control to my char-misc git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git in the char-misc-linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will hopefully also be merged in Linus's tree for the next -rc kernel release. If you have any questions about this process, please let me know. >From 5237c3175cae5ab05f18878cec3301a04403859e Mon Sep 17 00:00:00 2001 From: Rodrigo Alencar Date: Tue, 5 May 2026 13:35:04 +0100 Subject: iio: dac: ad5686: acquire lock when doing powerdown control Protect access of pwr_down_mode and pwr_down_mask fields with existing mutex lock. Each channel exposes their own attributes for controlling powerdown modes and powerdown state. This fixes potential race conditions as those the write functions perform non-atomic read-modify-write operations to those pwr_down_* fields. This issue exists since the ad5686 driver was first introduced. Fixes: c2f37c8dcadc ("iio: dac: New driver for AD5686R, AD5685R, AD5684R Digital to analog converters") Signed-off-by: Rodrigo Alencar Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5686.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 27878a6318ff..2e443fcfeb39 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -30,6 +30,8 @@ static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev, { struct ad5686_state *st = iio_priv(indio_dev); + guard(mutex)(&st->lock); + return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1; } @@ -39,6 +41,8 @@ static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev, { struct ad5686_state *st = iio_priv(indio_dev); + guard(mutex)(&st->lock); + st->pwr_down_mode &= ~(0x3 << (chan->channel * 2)); st->pwr_down_mode |= ((mode + 1) << (chan->channel * 2)); @@ -57,6 +61,8 @@ static ssize_t ad5686_read_dac_powerdown(struct iio_dev *indio_dev, { struct ad5686_state *st = iio_priv(indio_dev); + guard(mutex)(&st->lock); + return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & (0x3 << (chan->channel * 2)))); } @@ -77,6 +83,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, if (ret) return ret; + guard(mutex)(&st->lock); + if (readin) st->pwr_down_mask |= (0x3 << (chan->channel * 2)); else -- 2.54.0