iio: Fix crash in trigger unregister
Subsystems (3)
Srinivas Pandruvada
maintainerPATCH 1/9 iio: Fix crash in trigger unregister
User space can write a triger name via trigger/current_trigger. But it is possible that it can't find this name. In this case iio_trigger_find_by_name will return NULL. Even if it is NULL, it sets indio_dev->trig to this NULL value. But when iio drivers calls iio_trigger_unregister, it will crash because it will try to dereference NULL pointer. So either every driver checks for NULL before calling iio_trigger_unregister or make sure that NULL is not assigned because of invalid trigger name. The later is better and has less impact.
--- drivers/iio/industrialio-trigger.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/industrialio-trigger.c +5 -2
@@ -342,13 +342,16 @@ static ssize_t iio_trigger_write_current(struct device *dev,if (oldtrig == trig)return len; -if (trig && indio_dev->info->validate_trigger) { +if (!trig) +return -EINVAL ; + +if (indio_dev->info->validate_trigger) { ret = indio_dev->info->validate_trigger (indio_dev, trig);if (ret)return ret; } -if (trig && trig->ops && trig->ops->validate_device) { +if (trig->ops && trig->ops->validate_device) { ret = trig->ops->validate_device (trig, indio_dev);if (ret)return ret;
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 2/9 iio: hid-sensors: Add connection type
Some sensor hub firmware are very strict about the connection type setting. The connection type specifies whether it is an integrated or external sensor hub.
By default choosing integrated type unless changed via a module param.
Also a fix a minor typo for POWER_STATE.
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 12 +++++++++--- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 8 ++++++++ include/linux/hid-sensor-hub.h | 1 + include/linux/hid-sensor-ids.h | 6 +++++- 4 files changed, 23 insertions(+), 4 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +9 -3
@@ -226,7 +226,7 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,sensor_hub_input_get_attribute_info (hsdev,HID_FEATURE_REPORT , usage_id, -HID_USAGE_SENSOR_PROY_POWER_STATE , +HID_USAGE_SENSOR_PROT_POWER_STATE , &st->power_state); sensor_hub_input_get_attribute_info(hsdev,
@@ -234,11 +234,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS , &st->sensitivity); -hid_dbg (hsdev->hdev,"common attributes: %x:%x, %x:%x, %x:%x %x:%x\n" , +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE , + &st->conn_type); + +hid_dbg (hsdev->hdev,"common attributes: %x:%x, %x:%x, %x:%x %x:%x %x:%x\n" , st->poll.index, st->poll.report_id, st->report_state.index, st->report_state.report_id, st->power_state.index, st->power_state.report_id, - st->sensitivity.index, st->sensitivity.report_id); + st->sensitivity.index, st->sensitivity.report_id, + st->conn_type.index, st->conn_type.report_id);return 0 ; }
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +8 -0
@@ -34,6 +34,10 @@ module_param(hid_sensor_named_array_base, int, 0644);MODULE_PARM_DESC (hid_sensor_named_array_base,"HID SENSOR NAMED ARRAY BASE (0 or 1)." ); +static int hid_sensor_conn_type =HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM ; +module_param (hid_sensor_conn_type, int,0644 ); +MODULE_PARM_DESC (hid_sensor_conn_type,"HID SENSOR CONNECT TYPE (1 to 3)." ); +static int hid_sensor_data_rdy_trigger_set_state (struct iio_trigger *trig,bool state) {
@@ -68,6 +72,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, st->report_state.index, (s32)report_state); +sensor_hub_set_feature (st->hsdev, st->conn_type.report_id, + st->conn_type.index, + hid_sensor_conn_type); +return 0 ; }
include/linux/hid-sensor-hub.h +1 -0
@@ -188,6 +188,7 @@ struct hid_sensor_common {struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;struct hid_sensor_hub_attribute_info sensitivity; +struct hid_sensor_hub_attribute_info conn_type; };/* Convert from hid unit expo to regular exponent */
include/linux/hid-sensor-ids.h +5 -1
@@ -106,6 +106,7 @@#define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND 0x15/* Common selectors */ +#define HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE 0x200309#define HID_USAGE_SENSOR_PROP_REPORT_INTERVAL 0x20030E#define HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS 0x20030F#define HID_USAGE_SENSOR_PROP_SENSITIVITY_RANGE_PCT 0x200310
@@ -115,7 +116,10 @@#define HID_USAGE_SENSOR_PROP_RANGE_MAXIMUM 0x200314#define HID_USAGE_SENSOR_PROP_RANGE_MINIMUM 0x200315#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 -#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 +#define HID_USAGE_SENSOR_PROT_POWER_STATE 0x200319 + +/* Default connection type */ +#define HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM 0x01/* Power state enumerations */ #define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x00
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 3/9 iio: hid-sensors: accelerometer: Add sensitivity
In reply to Srinivas PandruvadaA number of Properties that can be applied to Data Fields are per data field basis or for all data fields. Adding sensitivity field for all accelerometer fields, which is most commonly used in currently available sensor hubs.
--- drivers/iio/accel/hid-sensor-accel-3d.c | 12 ++++++++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 13 insertions(+)
drivers/iio/accel/hid-sensor-accel-3d.c +12 -0
@@ -261,6 +261,18 @@ static int accel_3d_parse_report(struct platform_device *pdev, st->accel[1 ].index, st->accel[1 ].report_id, st->accel[2].index, st->accel[2].report_id); +/* Set Sensitivity field ids, when there is no individual modifier */ +if (st->common_attributes.sensitivity.index <0 ) { +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | +HID_USAGE_SENSOR_DATA_ACCELERATION , + &st->common_attributes.sensitivity); +dev_dbg (&pdev->dev,"Sensitivity index:report %d:%d\n" , + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + } +return ret; }
include/linux/hid-sensor-ids.h +1 -0
@@ -23,6 +23,7 @@/* Accel 3D (200073) */ #define HID_USAGE_SENSOR_ACCEL_3D 0x200073 +#define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452#define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453#define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454#define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 4/9 iio: hid-sensors: gyro : Add sensitivity
In reply to Srinivas PandruvadaA number of Properties that can be applied to Data Fields are per data field basis or for all data fields. Adding sensitivity field for all gyro fields, which is most commonly used in currently available sensor hubs.
--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 +++++++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 12 insertions(+)
drivers/iio/gyro/hid-sensor-gyro-3d.c +11 -0
@@ -261,6 +261,17 @@ static int gyro_3d_parse_report(struct platform_device *pdev, st->gyro[1 ].index, st->gyro[1 ].report_id, st->gyro[2].index, st->gyro[2].report_id); +/* Set Sensitivity field ids, when there is no individual modifier */ +if (st->common_attributes.sensitivity.index <0 ) { +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | +HID_USAGE_SENSOR_DATA_ANGL_VELOCITY , + &st->common_attributes.sensitivity); +dev_dbg (&pdev->dev,"Sensitivity index:report %d:%d\n" , + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + }return ret; }
include/linux/hid-sensor-ids.h +1 -0
@@ -34,6 +34,7 @@/* Gyro 3D: (200076) */ #define HID_USAGE_SENSOR_GYRO_3D 0x200076 +#define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456#define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457#define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458#define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 5/9 iio: hid-sensors: light/als : Add sensitivity
In reply to Srinivas PandruvadaA number of Properties that can be applied to Data Fields are per data field basis or for all data fields. Adding sensitivity field for all als fields, which is most commonly used in currently available sensor hubs.
--- drivers/iio/light/hid-sensor-als.c | 11 +++++++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 12 insertions(+)
drivers/iio/light/hid-sensor-als.c +11 -0
@@ -228,6 +228,17 @@ static int als_parse_report(struct platform_device *pdev,dev_dbg (&pdev->dev,"als %x:%x\n" , st->als_illum.index, st->als_illum.report_id); +/* Set Sensitivity field ids, when there is no individual modifier */ +if (st->common_attributes.sensitivity.index <0 ) { +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | +HID_USAGE_SENSOR_DATA_LIGHT , + &st->common_attributes.sensitivity); +dev_dbg (&pdev->dev,"Sensitivity index:report %d:%d\n" , + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + }return ret; }
include/linux/hid-sensor-ids.h +1 -0
@@ -30,6 +30,7 @@/* ALS (200041) */ #define HID_USAGE_SENSOR_ALS 0x200041 +#define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0#define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1/* Gyro 3D: (200076) */
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 6/9 iio: hid-sensors: magnetometer : Add sensitivity
In reply to Srinivas PandruvadaA number of Properties that can be applied to Data Fields are per data field basis or for all data fields. Adding sensitivity field for all magnetometer fields, which is most commonly used in currently available sensor hubs.
--- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/iio/magnetometer/hid-sensor-magn-3d.c +12 -0
@@ -262,6 +262,18 @@ static int magn_3d_parse_report(struct platform_device *pdev, st->magn[1 ].index, st->magn[1 ].report_id, st->magn[2].index, st->magn[2].report_id); +/* Set Sensitivity field ids, when there is no individual modifier */ +if (st->common_attributes.sensitivity.index <0 ) { +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | +HID_USAGE_SENSOR_DATA_ORIENTATION , + &st->common_attributes.sensitivity); +dev_dbg (&pdev->dev,"Sensitivity index:report %d:%d\n" , + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + } +return ret; }
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 7/9 iio: hid-sensors: Added Inclinometer 3D
In reply to Srinivas PandruvadaAdded usage id processing for Inclinometer 3D. This uses IIO interfaces for triggered buffer to present data to user mode.This uses HID sensor framework for registering callback events from the sensor hub.
--- drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/orientation/Kconfig | 19 ++ drivers/iio/orientation/Makefile | 6 + drivers/iio/orientation/hid-sensor-incl-3d.c | 428 +++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 9 + 6 files changed, 464 insertions(+) create mode 100644 drivers/iio/orientation/Kconfig create mode 100644 drivers/iio/orientation/Makefile create mode 100644 drivers/iio/orientation/hid-sensor-incl-3d.c
drivers/iio/Kconfig +1 -0
@@ -68,6 +68,7 @@ source "drivers/iio/gyro/Kconfig" source "drivers/iio/imu/Kconfig" source "drivers/iio/light/Kconfig" source "drivers/iio/magnetometer/Kconfig" +source "drivers/iio/orientation/Kconfig" if IIO_TRIGGER source "drivers/iio/trigger/Kconfig" endif #IIO_TRIGGER
drivers/iio/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-y += frequency/ obj-y += imu/ obj-y += light/ obj-y += magnetometer/ +obj-y += orientation/ obj-y += pressure/ obj-y += temperature/ obj-y += trigger/
drivers/iio/orientation/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# +# Inclinometer sensors +# +# When adding new entries keep the list in alphabetical order + +menu "Inclinometer sensors" + +config HID_SENSOR_INCLINOMETER_3D + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID Inclinometer 3D" + help + Say yes here to build support for the HID SENSOR + Inclinometer 3D. + +endmenu
drivers/iio/orientation/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for industrial I/O Inclinometer sensor drivers +# + +# When adding new entries keep the list in alphabetical order +obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o
drivers/iio/orientation/hid-sensor-incl-3d.c new file +428 -0
428 lines not on this page · raw message
include/linux/hid-sensor-ids.h +9 -0
@@ -42,6 +42,7 @@/* ORIENTATION: Compass 3D: (200083) */ #define HID_USAGE_SENSOR_COMPASS_3D 0x200083 +#define HID_USAGE_SENSOR_DATA_ORIENTATION 0x200470#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING 0x200471#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X 0x200472#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y 0x200473
@@ -57,10 +58,14 @@#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Y 0x20047B#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Z 0x20047C#define HID_USAGE_SENSOR_ORIENT_DISTANCE_OUT_OF_RANGE 0x20047D + +/* ORIENTATION: Inclinometer 3D: (200086) */ +#define HID_USAGE_SENSOR_INCLINOMETER_3D 0x200086#define HID_USAGE_SENSOR_ORIENT_TILT 0x20047E#define HID_USAGE_SENSOR_ORIENT_TILT_X 0x20047F#define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480#define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481 +#define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482#define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
@@ -136,4 +141,8 @@#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x00#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x01 +/* Per data field properties */ +#define HID_USAGE_SENSOR_DATA_MOD_NONE 0x00 +#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS 0x1000 +#endif
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 8/9 iio: Add channel modifiers for Quaternion Rotations
In reply to Srinivas PandruvadaA quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/iio/industrialio-core.c +4 -0
@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */
include/linux/iio/types.h +4 -0
@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1
Signature · 1 line
1.8.3.1
Srinivas Pandruvada
maintainerPATCH 9/9 iio: hid-sensors: Added device rotation support
In reply to Srinivas PandruvadaAdded usage id processing for device rotation. This uses IIO interfaces for triggered buffer to present data to user mode.This uses HID sensor framework for registering callback events from the sensor hub.
Data is exported to user space in the form quaternion rotation components.
--- drivers/iio/orientation/Kconfig | 11 + drivers/iio/orientation/Makefile | 1 + drivers/iio/orientation/hid-sensor-rotation.c | 426 ++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 1 + 4 files changed, 439 insertions(+) create mode 100644 drivers/iio/orientation/hid-sensor-rotation.c
drivers/iio/orientation/Kconfig +11 -0
@@ -16,4 +16,15 @@ config HID_SENSOR_INCLINOMETER_3D Say yes here to build support for the HID SENSOR Inclinometer 3D. +config HID_SENSOR_DEVICE_ROTATION + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID Device Rotation" + help + Say yes here to build support for the HID SENSOR + device rotation. + endmenu
drivers/iio/orientation/Makefile +1 -0
@@ -4,3 +4,4 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o +obj-$(CONFIG_HID_SENSOR_DEVICE_ROTATION) += hid-sensor-rotation.o
drivers/iio/orientation/hid-sensor-rotation.c new file +426 -0
426 lines not on this page · raw message
include/linux/hid-sensor-ids.h +1 -0
@@ -66,6 +66,7 @@#define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480#define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481 +#define HID_USAGE_SENSOR_DEVICE_ORIENTATION 0x20008A#define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482#define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
Signature · 1 line
1.8.3.1
Jonathan Cameron
maintainerQuoted 10 lines · Srinivas Pandruvada
User space can write a triger name via trigger/current_trigger. But it is possible that it can't find this name. In this case
iio_trigger_find_by_namewill return NULL. Even if it is NULL, it setsindio_dev->trigto this NULL value. But when iio drivers callsiio_trigger_unregister, it will crash because it will try to dereference NULL pointer. So either every driver checks for NULL before callingiio_trigger_unregisteror make sure that NULL is not assigned because of invalid trigger name. The later is better and has less impact.
Quoted 2 lines
Signed-off-by: Srinivas Pandruvada
<[email protected]>
Sorry to say I missed this in review.Indio_dev->trig is a pointer to the trigger being used by the device NOT the trigger provided by the device. If the device provides a trigger, the pointer to that is stored somewhere in iio_priv.
Hence the bug is not in the core but in the sensor hub trigger creation and freeing code.
Sorry again that I did not pick up on this before as this is not the first driver to confuse this. In mitigation it is clearly documented as intern (i.e. not for driver assignment) in iio.h
When I get a few mins I will check if we have any other equivalent cases that have slipped through the net...
Jonathan
Quoted 29 lines
---
drivers/iio/industrialio-trigger.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/iio/industrialio-trigger.c +5
-2@@ -342,13 +342,16 @@ static ssize_t iio_trigger_write_current(struct device *dev, if (oldtrig == trig)return len; -if (trig && indio_dev->info->validate_trigger) { +if (!trig) +return -EINVAL ; + +if (indio_dev->info->validate_trigger) { ret = indio_dev->info->validate_trigger (indio_dev, trig);if (ret)return ret; } -if (trig && trig->ops && trig->ops->validate_device) { +if (trig->ops && trig->ops->validate_device) { ret = trig->ops->validate_device (trig, indio_dev);if (ret)return ret;
Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Srinivas Pandruvada
maintainerQuoted 14 lines · Jonathan Cameron
Quoted 10 lines · Srinivas Pandruvada
User space can write a triger name via trigger/current_trigger. But it is possible that it can't find this name. In this case
iio_trigger_find_by_namewill return NULL. Even if it is NULL, it setsindio_dev->trigto this NULL value. But when iio drivers callsiio_trigger_unregister, it will crash because it will try to dereference NULL pointer. So either every driver checks for NULL before callingiio_trigger_unregisteror make sure that NULL is not assigned because of invalid trigger name. The later is better and has less impact.Quoted 2 lines
Signed-off-by: Srinivas Pandruvada
<[email protected]>
Quoted 8 lines
Sorry to say I missed this in review.
Indio_dev->trigis a pointer to the trigger being used by the device NOT the trigger provided by the device. If the device provides a trigger, the pointer to that is stored somewhere iniio_priv.Hence the bug is not in the core but in the sensor hub trigger creation and freeing code.
Sorry again that I did not pick up on this before as this is not the first driver to confuse this. In mitigation it is clearly documented as intern (i.e. not for driver assignment) in
iio.hWhen I get a few mins I will check if we have any other equivalent cases that have slipped through the net...
<Thanks for pointing this. I will fix in sensor hub driver and resubmit.>
Srinivas
Quoted 30 lines
Jonathan
Quoted 29 lines
---
drivers/iio/industrialio-trigger.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/iio/industrialio-trigger.c +5
-2@@ -342,13 +342,16 @@ static ssize_t iio_trigger_write_current(struct device *dev, if (oldtrig == trig)return len; -if (trig && indio_dev->info->validate_trigger) { +if (!trig) +return -EINVAL ; + +if (indio_dev->info->validate_trigger) { ret = indio_dev->info->validate_trigger (indio_dev, trig);if (ret)return ret; } -if (trig && trig->ops && trig->ops->validate_device) { +if (trig->ops && trig->ops->validate_device) { ret = trig->ops->validate_device (trig, indio_dev);if (ret)return ret;