Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: light: tcs3472: Use iio_push_to_buffers_with_ts() to allow source size runtime check

Use iio_push_to_buffers_with_ts() to allow source size runtime check.

Also move the structure used as the source to the stack as it is only 16
bytes and not the target of an DMA or similar.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250802164436.515988-14-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+7 -7
+7 -7
drivers/iio/light/tcs3472.c
··· 64 64 u8 control; 65 65 u8 atime; 66 66 u8 apers; 67 - /* Ensure timestamp is naturally aligned */ 68 - struct { 69 - u16 chans[4]; 70 - aligned_s64 timestamp; 71 - } scan; 72 67 }; 73 68 74 69 static const struct iio_event_spec tcs3472_events[] = { ··· 372 377 struct iio_dev *indio_dev = pf->indio_dev; 373 378 struct tcs3472_data *data = iio_priv(indio_dev); 374 379 int i, j = 0; 380 + /* Ensure timestamp is naturally aligned */ 381 + struct { 382 + u16 chans[4]; 383 + aligned_s64 timestamp; 384 + } scan = { }; 375 385 376 386 int ret = tcs3472_req_data(data); 377 387 if (ret < 0) ··· 388 388 if (ret < 0) 389 389 goto done; 390 390 391 - data->scan.chans[j++] = ret; 391 + scan.chans[j++] = ret; 392 392 } 393 393 394 - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, 394 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 395 395 iio_get_time_ns(indio_dev)); 396 396 397 397 done: