summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <dlechner@baylibre.com>2025-07-01 16:37:49 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-20 18:30:24 +0200
commitc0d5054684f00ea27ccd0e756100dd94274d888c (patch)
treeb1a0b21b52307f3ef39bbcd1623a8cf2b1eb8a85
parentc8db5c7a00b1c4e34bcad25631a778e2921ac0d4 (diff)
iio: adc: ad_sigma_delta: don't overallocate scan buffer
[ Upstream commit 5a2f15c5a8e017d0951e6dc62aa7b5b634f56881 ] Fix overallocating the size of the scan buffer by converting bits to bytes. The size is meant to be in bytes, so scanbits needs to be divided by 8. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250701-iio-adc-ad7173-add-spi-offload-support-v3-1-42abb83e3dac@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/iio/adc/ad_sigma_delta.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 3df1d4f6bc95..39196a2862cf 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -379,7 +379,7 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
return ret;
}
- samples_buf_size = ALIGN(slot * indio_dev->channels[0].scan_type.storagebits, 8);
+ samples_buf_size = ALIGN(slot * indio_dev->channels[0].scan_type.storagebits / 8, 8);
samples_buf_size += sizeof(int64_t);
samples_buf = devm_krealloc(&sigma_delta->spi->dev, sigma_delta->samples_buf,
samples_buf_size, GFP_KERNEL);