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

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

+9 -8
-5
drivers/iio/light/st_uvis25.h
··· 27 27 struct iio_trigger *trig; 28 28 bool enabled; 29 29 int irq; 30 - /* Ensure timestamp is naturally aligned */ 31 - struct { 32 - u8 chan; 33 - aligned_s64 ts; 34 - } scan; 35 30 }; 36 31 37 32 extern const struct dev_pm_ops st_uvis25_pm_ops;
+9 -3
drivers/iio/light/st_uvis25_core.c
··· 234 234 struct st_uvis25_hw *hw = iio_priv(iio_dev); 235 235 unsigned int val; 236 236 int err; 237 + /* Ensure timestamp is naturally aligned */ 238 + struct { 239 + u8 chan; 240 + aligned_s64 ts; 241 + } scan = { }; 242 + 237 243 238 244 err = regmap_read(hw->regmap, ST_UVIS25_REG_OUT_ADDR, &val); 239 245 if (err < 0) 240 246 goto out; 241 247 242 - hw->scan.chan = val; 248 + scan.chan = val; 243 249 244 - iio_push_to_buffers_with_timestamp(iio_dev, &hw->scan, 245 - iio_get_time_ns(iio_dev)); 250 + iio_push_to_buffers_with_ts(iio_dev, &scan, sizeof(scan), 251 + iio_get_time_ns(iio_dev)); 246 252 247 253 out: 248 254 iio_trigger_notify_done(hw->trig);