Skip to content

Commit d443a0a

Browse files
hongyansJiri Kosina
authored andcommitted
HID: hid-sensor-hub: clear memory to avoid random data
When user tried to read some fields like hysteresis from IIO sysfs on some systems, it fails. The reason is that this field is a byte field and caller of sensor_hub_get_feature() passes a buffer of 4 bytes. Here the function sensor_hub_get_feature() copies the single byte from the report to the caller buffer and returns "1" as the number of bytes copied. So caller can use the return value. But this is done by multiple callers, so if we just change the sensor_hub_get_feature so that caller buffer is initialized with 0s then we don't to change all functions. Signed-off-by: Song Hongyan <hongyan.song@intel.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 6dab07d commit d443a0a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hid/hid-sensor-hub.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
212212
__s32 value;
213213
int ret = 0;
214214

215+
memset(buffer, 0, buffer_size);
215216
mutex_lock(&data->mutex);
216217
report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
217218
if (!report || (field_index >= report->maxfield)) {

0 commit comments

Comments
 (0)