Skip to content

Commit a1c9f50

Browse files
keesjic23
authored andcommitted
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: ClangBuiltLinux#2000 [1] Fixes: ac78c6a ("iio: pressure: Add driver for DLH pressure sensors") Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Andy 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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent daec424 commit a1c9f50

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/iio/pressure/dlhl60d.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,17 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private)
250250
struct dlh_state *st = iio_priv(indio_dev);
251251
int ret;
252252
unsigned int chn, i = 0;
253-
__be32 tmp_buf[2];
253+
__be32 tmp_buf[2] = { };
254254

255255
ret = dlh_start_capture_and_read(st);
256256
if (ret)
257257
goto out;
258258

259259
for_each_set_bit(chn, indio_dev->active_scan_mask,
260-
indio_dev->masklength) {
261-
memcpy(tmp_buf + i,
260+
indio_dev->masklength) {
261+
memcpy(&tmp_buf[i++],
262262
&st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES,
263263
DLH_NUM_DATA_BYTES);
264-
i++;
265264
}
266265

267266
iio_push_to_buffers(indio_dev, tmp_buf);

0 commit comments

Comments
 (0)