linux-stable/drivers/iio
Milan Zamazal 312f04ede2 iio: core: Prevent invalid memory access when there is no parent
commit b2a6996990 upstream.

Commit 813665564b ("iio: core: Convert to use firmware node handle
instead of OF node") switched the kind of nodes to use for label
retrieval in device registration.  Probably an unwanted change in that
commit was that if the device has no parent then NULL pointer is
accessed.  This is what happens in the stock IIO dummy driver when a
new entry is created in configfs:

  # mkdir /sys/kernel/config/iio/devices/dummy/foo
  BUG: kernel NULL pointer dereference, address: ...
  ...
  Call Trace:
  __iio_device_register
  iio_dummy_probe

Since there seems to be no reason to make a parent device of an IIO
dummy device mandatory, let’s prevent the invalid memory access in
__iio_device_register when the parent device is NULL.  With this
change, the IIO dummy driver works fine with configfs.

Fixes: 813665564b ("iio: core: Convert to use firmware node handle instead of OF node")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Link: https://lore.kernel.org/r/20230719083208.88149-1-mzamazal@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-16 18:27:25 +02:00
..
accel iio: accel: fxls8962af: fixup buffer scan element type 2023-07-19 16:21:46 +02:00
adc iio: adc: ina2xx: avoid NULL pointer dereference on OF device match 2023-08-16 18:27:24 +02:00
addac iio: addac: ad74413: fix resistance input processing 2023-06-09 10:34:19 +02:00
afe
amplifiers
buffer
cdc
chemical
common iio: cros_ec: Fix the allocation size for cros_ec_command 2023-08-16 18:27:24 +02:00
dac iio: dac: build ad5758 driver when AD5758 is selected 2023-06-09 10:34:19 +02:00
dummy
filter
frequency iio: frequency: admv1013: propagate errors from regulator_get_voltage() 2023-08-16 18:27:24 +02:00
gyro iio: hid: fix the retval in gyro_3d_capture_sample 2023-02-09 11:28:17 +01:00
health
humidity
imu iio: imu: inv_icm42600: fix timestamp reset 2023-06-09 10:34:18 +02:00
light iio: light: vcnl4035: fixed chip ID check 2023-06-09 10:34:18 +02:00
magnetometer
multiplexer
orientation
position
potentiometer
potentiostat
pressure
proximity
resolver
temperature
test
trigger
Kconfig
Makefile
TODO
iio_core.h
iio_core_trigger.h
industrialio-buffer.c iio: buffer: make sure O_NONBLOCK is respected 2023-04-13 16:55:27 +02:00
industrialio-configfs.c
industrialio-core.c iio: core: Prevent invalid memory access when there is no parent 2023-08-16 18:27:25 +02:00
industrialio-event.c iio: fix memory leak in iio_device_register_eventset() 2022-12-31 13:33:10 +01:00
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c