Commit a1c9f508 authored by Kees Cook's avatar Kees Cook Committed by Jonathan Cameron

iio: pressure: dlhl60d: Initialize empty DLH bytes

3 bytes were being read but 4 were being written. Explicitly initialize
the unused bytes to 0 and refactor the loop to use direct array
indexing, which appears to silence a Clang false positive warning[1].

Indent improvement included for readability of the fixed code.

Link: https://github.com/ClangBuiltLinux/linux/issues/2000 [1]
Fixes: ac78c6aa ("iio: pressure: Add driver for DLH pressure sensors")
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240223172936.it.875-kees@kernel.org
Cc: <Stable@vger.kerenl.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent daec424c
...@@ -250,18 +250,17 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private) ...@@ -250,18 +250,17 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private)
struct dlh_state *st = iio_priv(indio_dev); struct dlh_state *st = iio_priv(indio_dev);
int ret; int ret;
unsigned int chn, i = 0; unsigned int chn, i = 0;
__be32 tmp_buf[2]; __be32 tmp_buf[2] = { };
ret = dlh_start_capture_and_read(st); ret = dlh_start_capture_and_read(st);
if (ret) if (ret)
goto out; goto out;
for_each_set_bit(chn, indio_dev->active_scan_mask, for_each_set_bit(chn, indio_dev->active_scan_mask,
indio_dev->masklength) { indio_dev->masklength) {
memcpy(tmp_buf + i, memcpy(&tmp_buf[i++],
&st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES, &st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES,
DLH_NUM_DATA_BYTES); DLH_NUM_DATA_BYTES);
i++;
} }
iio_push_to_buffers(indio_dev, tmp_buf); iio_push_to_buffers(indio_dev, tmp_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment