OSDN Git Service

iio: Don't silently expect attribute types
authorMatti Vaittinen <mazziesaccount@gmail.com>
Mon, 3 Oct 2022 08:13:53 +0000 (11:13 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 23 Nov 2022 19:44:04 +0000 (19:44 +0000)
commit0a33755c4b01ed62a6d025cb585928304f9653d7
tree9bc4e8f56366dd67dae9bdcef6d073d1919ab705
parentc1531e3ad43f5e66cd04ae19644343b9222204d2
iio: Don't silently expect attribute types

The iio_triggered_buffer_setup_ext() and the
devm_iio_kfifo_buffer_setup_ext() were changed by
commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
to silently expect that all attributes given in buffer_attrs array are
device-attributes. This expectation was not forced by the API - and some
drivers did register attributes created by IIO_CONST_ATTR().

When using IIO_CONST_ATTRs the added attribute "wrapping" does not copy
the pointer to stored string constant and when the sysfs file is read the
kernel will access to invalid location.

Change the function signatures to expect an array of iio_dev_attrs to
avoid similar errors in the future.

Merge conflict resolved whilst applying due to patch crossing with
two new drivers (kx022a accelerometer and ad4130 ADC).

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
15 files changed:
drivers/iio/accel/adxl367.c
drivers/iio/accel/adxl372.c
drivers/iio/accel/bmc150-accel-core.c
drivers/iio/accel/kionix-kx022a.c
drivers/iio/adc/ad4130.c
drivers/iio/adc/at91-sama5d2_adc.c
drivers/iio/buffer/industrialio-buffer-dmaengine.c
drivers/iio/buffer/industrialio-triggered-buffer.c
drivers/iio/buffer/kfifo_buf.c
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
drivers/iio/industrialio-buffer.c
include/linux/iio/buffer_impl.h
include/linux/iio/kfifo_buf.h
include/linux/iio/triggered_buffer.h