linux-stable/drivers/iio/proximity
GONG, Ruiqi ea191d0fd3 iio: irsd200: fix -Warray-bounds bug in irsd200_trigger_handler
When compiling with gcc 13 with -Warray-bounds enabled:

In file included from drivers/iio/proximity/irsd200.c:15:
In function ‘iio_push_to_buffers_with_timestamp’,
    inlined from ‘irsd200_trigger_handler’ at drivers/iio/proximity/irsd200.c:770:2:
./include/linux/iio/buffer.h:42:46: error: array subscript ‘int64_t {aka long long int}[0]’
is partly outside array bounds of ‘s16[1]’ {aka ‘short int[1]’} [-Werror=array-bounds=]
   42 |                 ((int64_t *)data)[ts_offset] = timestamp;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
drivers/iio/proximity/irsd200.c: In function ‘irsd200_trigger_handler’:
drivers/iio/proximity/irsd200.c:763:13: note: object ‘buf’ of size 2
  763 |         s16 buf = 0;
      |             ^~~

The problem seems to be that irsd200_trigger_handler() is taking a s16
variable as an int64_t buffer. As Jonathan suggested [1], fix it by
extending the buffer to a two-element array of s64.

Link: https://github.com/KSPP/linux/issues/331
Link: https://lore.kernel.org/lkml/20230809181329.46c00a5d@jic23-huawei/ [1]
Fixes: 3db3562bc6 ("iio: Add driver for Murata IRS-D200")
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Waqar Hameed <waqar.hameed@axis.com>
Tested-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230810035910.1334706-1-gongruiqi@huaweicloud.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-10-05 18:06:45 +01:00
..
as3935.c iio: Rename iio_trigger_poll_chained and add kernel-doc 2023-03-11 12:18:29 +00:00
cros_ec_mkbp_proximity.c iio: proximity: cros_ec_mkbp: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() 2022-07-18 18:48:18 +01:00
irsd200.c iio: irsd200: fix -Warray-bounds bug in irsd200_trigger_handler 2023-10-05 18:06:45 +01:00
isl29501.c iio: adc: Explicitly include correct DT includes 2023-07-23 13:38:13 +01:00
Kconfig iio: Add driver for Murata IRS-D200 2023-07-23 13:21:54 +01:00
Makefile iio: Add driver for Murata IRS-D200 2023-07-23 13:21:54 +01:00
mb1232.c iio: mb1232: relax return value check for IRQ get 2023-08-01 18:55:46 +01:00
ping.c
pulsedlight-lidar-lite-v2.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
rfd77402.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
srf04.c iio: proximity: srf04: Use pm_ptr() to remove unused struct dev_pm_ops 2022-09-21 18:42:56 +01:00
srf08.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx9310.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx9324.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx9360.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx9500.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx_common.c iio: proximity: sx_common: Add old register mapping 2023-03-11 12:18:28 +00:00
sx_common.h iio: proximity: sx_common: Add old register mapping 2023-03-11 12:18:28 +00:00
vcnl3020.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
vl53l0x-i2c.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00