Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795055116; b=kFy1uNrv6BqDMtzxxEVtKBmx/6590gAOSsYBLz5X+shk7ee+G8jSlgvuKmnqTRO6bNOi CGWYmdf0gAbZm0DZNp1Vp+J0YHUnSr8LiK8lIO7BncsEyWMMz2X9hk4y9G/aVYKfZuE2U 3Dk63mJeKSBP/RkKi0L3EYyl/GzJWhEMGkKcmTE8nJFqecdclwa4iJKCejyjAnHFNFRTx oCQUfdSl15+jauGvSMMhh7f8NAum9q9BIWHtyZ/DJAQAyILpUOTE6piZ7T2rMsmSZFTvI s2owvTxLRShX3bLEcTQgaRw5JUMW27gid8UdMJfR7kNC1Phf1DN5Obncs0X6SS2KHTA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795055116; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Oqs1feHc5GJv8Uq/expj4KQM90z9uT32p6x3vn1VTMk=; b=Cfso+Z+W7nTu0W5tgnf8gLPVrrTg9UZCI5jEYVKHfefQ3Gj8mzu3v7LkTTcKatrUKOU2 z3iSOiK+sJu54Kb2cE5BWDaUcQd/13PGn2B+UTQEPnswnXb/z1IL0VQbfmweFFR1f8c/8 tqeqaEfjVCZm72H4godPgq576rA/2QyiXPpTM+Dd/x7FCcTkcCXcKC7uDMkAydPrtxYdH 7WUB806aaW0D20LiMU0IkKxc8CB7T3/coAMDa4BA/FZczv7/UPjxTpUIlKklfIQItQ0jW ZGDDCXMc3V3VkZTyrsfaRhKBNb2lExTBHR8vyz7TjXazESsVJQWP/xWsYsPTiS+8rhw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="m9JttVS/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1188A606A325; Thu, 19 Nov 2026 02:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=m9JttVS/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 648B71F000C4; Thu, 19 Nov 2026 02:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795055115; bh=Oqs1feHc5GJv8Uq/expj4KQM90z9uT32p6x3vn1VTMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m9JttVS/pDlXxNa4TnCfJwBZ8i0JdGRd2w2X4xkzDBkzkkmrdCHQ3JxYvH77+URda 34myVUtnzJ5bAee6Lrw2OiNH2cR3P6Pq1SppAtuz3cjgKX2WDakCEU2vIpyHENfZnR T3IBAUabAhtR1YW9vYCunG87xWucFIgzctjHe9/A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Abdelnasser Hussein , Joshua Crofts , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.15 1517/2214] staging: iio: adc: ad7816: Fix DMA safety issues in SPI transfers Date: Wed, 18 Nov 2026 15:53:13 +0100 Message-ID: <20261118150112.743199648@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdelnasser Hussein [ Upstream commit 69fa76f0af3414cc189c3b0b807cb59e327ecc00 ] The SPI operations in this driver are not DMA safe: 1. spi_read() uses a stack-allocated buffer. 2. spi_write() in ad7816_spi_read() uses a struct member that shares a cacheline with other variables. 3. spi_write() in ad7816_spi_write() passes a stack parameter by reference. Fix these violations by replacing all spi_read() and spi_write() calls with spi_write_then_read(). This safely handles DMA by internally allocating a bounce buffer for the transfers, avoiding cacheline sharing issues without needing dedicated aligned buffers. This implicitly corrects the size argument in read to sizeof(buf). Fixes: 7924425db04a ("staging: iio: adc: new driver for AD7816 devices") Signed-off-by: Abdelnasser Hussein Reviewed-by: Joshua Crofts Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/staging/iio/adc/ad7816.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 081b17f498638..a46ca0559b6a2 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -69,7 +69,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) gpiod_set_value(chip->rdwr_pin, 1); gpiod_set_value(chip->rdwr_pin, 0); - ret = spi_write(spi_dev, &chip->channel_id, sizeof(chip->channel_id)); + ret = spi_write_then_read(spi_dev, &chip->channel_id, sizeof(chip->channel_id), NULL, 0); if (ret < 0) { dev_err(&spi_dev->dev, "SPI channel setting error\n"); return ret; @@ -91,7 +91,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) gpiod_set_value(chip->rdwr_pin, 0); gpiod_set_value(chip->rdwr_pin, 1); - ret = spi_read(spi_dev, &buf, sizeof(*data)); + ret = spi_write_then_read(spi_dev, NULL, 0, &buf, sizeof(buf)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI data read error\n"); return ret; @@ -109,7 +109,7 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data) gpiod_set_value(chip->rdwr_pin, 1); gpiod_set_value(chip->rdwr_pin, 0); - ret = spi_write(spi_dev, &data, sizeof(data)); + ret = spi_write_then_read(spi_dev, &data, sizeof(data), NULL, 0); if (ret < 0) dev_err(&spi_dev->dev, "SPI oti data write error\n"); -- 2.53.0