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 129461E98EF; Sun, 7 Jun 2026 10:43:36 +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=1780829017; cv=none; b=OqU3Kx/qZ08caR29B1NCgww9WID9r1hsgqSX6GePlwScqiieQzWlO+f6piiMl2h1UyLVkdh+S2RqwMCY5mFNPL8V/nIQu+zE5yCas1JFkf42u0eJJwcLCbhfmEvP4WwXDYVesqizJHrpR+gKv81Mdi8C8xhOjjVl0pbVlxfBl/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780829017; c=relaxed/simple; bh=ZOGWVz03phVcVckJwUhGLPBTy7gZ1nMGX3dr0gzgYyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=otBIJPSHoPkSPiSsTv3VXfJ2ZaFCjKI9GhHrbR/QLPl7CxUh6M1kLCtCCXYgxHWZOARUOsdvZIfc8YQp/cL8Z4eSbKBVDJ2pSgXXIadTDD23sWtOULhOvHAY0yO+E5e7uWr3fgN9BNH/jh292go4UpaeL5UfXy6kyAdgLmsNKi0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i6h8NvZu; 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="i6h8NvZu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2567C1F00893; Sun, 7 Jun 2026 10:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780829016; bh=BNNTjM3vcK0gzvAGuthVPyKo0Y/PshorzIzA5VGJ8SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i6h8NvZut7zX1JZlbxgMGZXtTMLSJHztnSQvRotqb/a3WrdCzqt617FwlMWhsgmR5 eFcI/4hiz6toDczWSGG11Ba5OKkekMTvA1apMjEzbbGNpGENvzHjEFZRdabnL9X4sc ETQCTSu76i1pS/xzEsH8MsVmMeKWxqvRHpiiMDog= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rodrigo Alencar , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.12 166/307] iio: dac: ad5686: acquire lock when doing powerdown control Date: Sun, 7 Jun 2026 11:59:23 +0200 Message-ID: <20260607095733.820319450@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@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-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rodrigo Alencar commit 5237c3175cae5ab05f18878cec3301a04403859e upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/iio/dac/ad5686.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -30,6 +30,8 @@ static int ad5686_get_powerdown_mode(str { 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(str { 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 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_powerdow if (ret) return ret; + guard(mutex)(&st->lock); + if (readin) st->pwr_down_mask |= (0x3 << (chan->channel * 2)); else