sst-linux/drivers/iio
Uwe Kleine-König 7098ae7ee2 iio: adc: ad7124: Fix comparison of channel configs
[ Upstream commit 05a5d874f7327b75e9bc4359618017e047cc129c ]

Checking the binary representation of two structs (of the same type)
for equality doesn't have the same semantic as comparing all members for
equality. The former might find a difference where the latter doesn't in
the presence of padding or when ambiguous types like float or bool are
involved. (Floats typically have different representations for single
values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
true, but memcmp finds a difference.)

When searching for a channel that already has the configuration we need,
the comparison by member is the one that is needed.

Convert the comparison accordingly to compare the members one after
another. Also add a static_assert guard to (somewhat) ensure that when
struct ad7124_channel_config::config_props is expanded, the comparison
is adapted, too.

This issue is somewhat theoretic, but using memcmp() on a struct is a
bad pattern that is worth fixing.

Fixes: 7b8d045e49 ("iio: adc: ad7124: allow more than 8 channels")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-13-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:36 +02:00
..
accel iio: accel: msa311: Fix failure to release runtime pm if direct mode claim fails. 2025-04-10 14:33:36 +02:00
adc iio: adc: ad7124: Fix comparison of channel configs 2025-04-10 14:33:36 +02:00
addac
afe
amplifiers iio: amplifiers: ada4250: add missing select REGMAP_SPI in Kconfig 2024-10-22 15:56:47 +02:00
buffer iio: buffer-dmaengine: fix releasing dma channel on error 2024-09-12 11:10:26 +02:00
cdc
chemical iio: chemical: bme680: Fix read/write ops to device by adding mutexes 2024-10-17 15:21:11 +02:00
common iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency() 2024-10-22 15:56:47 +02:00
dac iio: dac: ad3552r: clear reset status flag 2025-03-13 12:53:23 +01:00
dummy iio: dummy: iio_simply_dummy_buffer: fix information leak in triggered buffer 2025-01-17 13:34:45 +01:00
filter iio: filter: admv8818: Force initialization of SDO 2025-03-13 12:53:23 +01:00
frequency iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig 2024-11-01 01:55:58 +01:00
gyro iio: gyro: fxas21002c: Fix missing data update in trigger handler 2025-01-17 13:34:46 +01:00
health
humidity
imu iio: imu: inv_icm42600: fix timestamps after suspend if sensor is on 2025-01-23 17:17:15 +01:00
light iio: light: as73211: fix channel handling in only-color triggered buffer 2025-02-21 13:49:48 +01:00
magnetometer iio: magnetometer: yas530: use signed integer type for clamp limits 2024-12-14 19:54:31 +01:00
multiplexer
orientation
position
potentiometer
potentiostat
pressure iio: pressure: zpa2326: fix information leak in triggered buffer 2025-01-17 13:34:45 +01:00
proximity iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig 2024-10-22 15:56:48 +02:00
resolver
temperature
test
trigger
iio_core_trigger.h
iio_core.h
industrialio-buffer.c
industrialio-configfs.c
industrialio-core.c driver: iio: add missing checks on iio_info's callback access 2024-09-08 07:53:11 +02:00
industrialio-event.c driver: iio: add missing checks on iio_info's callback access 2024-09-08 07:53:11 +02:00
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c iio: inkern: call iio_device_put() only on mapped devices 2025-01-17 13:34:46 +01:00
Kconfig
Makefile
TODO