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

Configure Feed

Select the types of activity you want to include in your feed.

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

+9 -9
+9 -9
drivers/iio/light/max44000.c
··· 75 75 struct max44000_data { 76 76 struct mutex lock; 77 77 struct regmap *regmap; 78 - /* Ensure naturally aligned timestamp */ 79 - struct { 80 - u16 channels[2]; 81 - aligned_s64 ts; 82 - } scan; 83 78 }; 84 79 85 80 /* Default scale is set to the minimum of 0.03125 or 1 / (1 << 5) lux */ ··· 491 496 int index = 0; 492 497 unsigned int regval; 493 498 int ret; 499 + struct { 500 + u16 channels[2]; 501 + aligned_s64 ts; 502 + } scan = { }; 503 + 494 504 495 505 mutex_lock(&data->lock); 496 506 if (test_bit(MAX44000_SCAN_INDEX_ALS, indio_dev->active_scan_mask)) { 497 507 ret = max44000_read_alsval(data); 498 508 if (ret < 0) 499 509 goto out_unlock; 500 - data->scan.channels[index++] = ret; 510 + scan.channels[index++] = ret; 501 511 } 502 512 if (test_bit(MAX44000_SCAN_INDEX_PRX, indio_dev->active_scan_mask)) { 503 513 ret = regmap_read(data->regmap, MAX44000_REG_PRX_DATA, &regval); 504 514 if (ret < 0) 505 515 goto out_unlock; 506 - data->scan.channels[index] = regval; 516 + scan.channels[index] = regval; 507 517 } 508 518 mutex_unlock(&data->lock); 509 519 510 - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, 511 - iio_get_time_ns(indio_dev)); 520 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 521 + iio_get_time_ns(indio_dev)); 512 522 iio_trigger_notify_done(indio_dev->trig); 513 523 return IRQ_HANDLED; 514 524