Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()

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>

authored by

Srinivas Pandruvada and committed by
Jiri Kosina
3202f482 ca66a677

+5 -3
+5 -3
drivers/hid/hid-sensor-custom.c
··· 387 387 struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); 388 388 int index, field_index, usage; 389 389 char name[HID_CUSTOM_NAME_LENGTH]; 390 - int value; 390 + int value, ret; 391 391 392 392 if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage, 393 393 name) == 3) { ··· 403 403 404 404 report_id = sensor_inst->fields[field_index].attribute. 405 405 report_id; 406 - sensor_hub_set_feature(sensor_inst->hsdev, report_id, 407 - index, sizeof(value), &value); 406 + ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id, 407 + index, sizeof(value), &value); 408 + if (ret) 409 + return ret; 408 410 } else 409 411 return -EINVAL; 410 412