]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Thu, 15 Apr 2021 18:52:32 +0000 (11:52 -0700)
committerJiri Kosina <jkosina@suse.cz>
Wed, 26 May 2021 10:36:46 +0000 (12:36 +0200)
When user modifies a custom feature value and sensor_hub_set_feature()
fails, return error.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-sensor-custom.c

index 2e6662173a79c0b6f2b6a82496248c5227fce7cc..32c2306e240d605944b1d0d2fd957c897f1d407a 100644 (file)
@@ -387,7 +387,7 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr,
        struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
        int index, field_index, usage;
        char name[HID_CUSTOM_NAME_LENGTH];
-       int value;
+       int value, ret;
 
        if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage,
                   name) == 3) {
@@ -403,8 +403,10 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr,
 
                report_id = sensor_inst->fields[field_index].attribute.
                                                                report_id;
-               sensor_hub_set_feature(sensor_inst->hsdev, report_id,
-                                      index, sizeof(value), &value);
+               ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id,
+                                            index, sizeof(value), &value);
+               if (ret)
+                       return ret;
        } else
                return -EINVAL;