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

iio: light: isl29125: 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: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250802164436.515988-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+7 -7
+7 -7
drivers/iio/light/isl29125.c
··· 51 51 struct isl29125_data { 52 52 struct i2c_client *client; 53 53 u8 conf1; 54 - /* Ensure timestamp is naturally aligned */ 55 - struct { 56 - u16 chans[3]; 57 - aligned_s64 timestamp; 58 - } scan; 59 54 }; 60 55 61 56 #define ISL29125_CHANNEL(_color, _si) { \ ··· 174 179 struct iio_dev *indio_dev = pf->indio_dev; 175 180 struct isl29125_data *data = iio_priv(indio_dev); 176 181 int i, j = 0; 182 + /* Ensure timestamp is naturally aligned */ 183 + struct { 184 + u16 chans[3]; 185 + aligned_s64 timestamp; 186 + } scan = { }; 177 187 178 188 iio_for_each_active_channel(indio_dev, i) { 179 189 int ret = i2c_smbus_read_word_data(data->client, ··· 186 186 if (ret < 0) 187 187 goto done; 188 188 189 - data->scan.chans[j++] = ret; 189 + scan.chans[j++] = ret; 190 190 } 191 191 192 - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, 192 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 193 193 iio_get_time_ns(indio_dev)); 194 194 195 195 done: