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

iio: light: tcs3414: 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-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+8 -7
+8 -7
drivers/iio/light/tcs3414.c
··· 53 53 u8 control; 54 54 u8 gain; 55 55 u8 timing; 56 - /* Ensure timestamp is naturally aligned */ 57 - struct { 58 - u16 chans[4]; 59 - aligned_s64 timestamp; 60 - } scan; 61 56 }; 62 57 63 58 #define TCS3414_CHANNEL(_color, _si, _addr) { \ ··· 199 204 struct iio_dev *indio_dev = pf->indio_dev; 200 205 struct tcs3414_data *data = iio_priv(indio_dev); 201 206 int i, j = 0; 207 + /* Ensure timestamp is naturally aligned */ 208 + struct { 209 + u16 chans[4]; 210 + aligned_s64 timestamp; 211 + } scan = { }; 212 + 202 213 203 214 iio_for_each_active_channel(indio_dev, i) { 204 215 int ret = i2c_smbus_read_word_data(data->client, ··· 212 211 if (ret < 0) 213 212 goto done; 214 213 215 - data->scan.chans[j++] = ret; 214 + scan.chans[j++] = ret; 216 215 } 217 216 218 - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, 217 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 219 218 iio_get_time_ns(indio_dev)); 220 219 221 220 done: