STMicroelectronics / STMems_Android_Sensor_HAL_IIO

DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer to https://github.com/STMicroelectronics/st-mems-android-linux-sensors-hal for the up-to-date HAL repository. This repository contains ST Android sensor Hardware Abstraction Layer (HAL) for MEMS Linux IIO drivers
Apache License 2.0
34 stars 21 forks source link

SIGSEGV if there no /sys/bus/iio/devices/ #5

Closed ramok closed 4 years ago

ramok commented 4 years ago

If there is no /sys/bus/iio/devices/, there is a problem:

D/SensorHAL( 961): -2 IIO devices available into /sys/bus/iio/devices/ folder. D/SensorHAL( 961): "": IIO device not supported by sensor HAL. D/SensorHAL( 961): "Ь≈з═<7f>": IIO device not supported by sensor HAL. .. F/libc ( 722): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7f6b0d500c in tid 740 (system_server) .. I/DEBUG ( 254): #01 pc 00000000000078cc /system/vendor/lib64/hw/sensors.msm8916.so (st_hal_load_iio_devices_data(STSensorHAL_iio_devices_data*)+316)

This chunk need to be revert: https://github.com/STMicroelectronics/STMems_Android_Sensor_HAL_IIO/commit/8abda16ebb959341999278420bcb2efba5ed63ca#diff-baf53f11b0a71c17833b6ca4bafa2e46

device_iio_utils::get_devices_name() return -2 to unsigned iio_devices_num. Which cannot be checked for -2

  unsigned int i, n, iio_devices_num;
  struct device_iio_type_name iio_devices[ST_HAL_IIO_MAX_DEVICES];

  iio_devices_num =  device_iio_utils::get_devices_name(iio_devices,
                                ST_HAL_IIO_MAX_DEVICES);
  if (iio_devices_num <= 0)
      return iio_devices_num;

#if (CONFIG_ST_HAL_DEBUG_LEVEL >= ST_HAL_DEBUG_VERBOSE)
    ALOGD("%d IIO devices available into /sys/bus/iio/devices/ folder.", iio_devices_num);
#endif /* CONFIG_ST_HAL_DEBUG_LEVEL */
mariotesi commented 4 years ago

Hi Ramok,

I think the issue in this commit is changing the i and n variables to unsigned int, I'm going to revert this change and test it again in the suggested condition (without any IIO sensors detected)

Shortly I'll update it on GitHub

Thank you and Best Regards