HID: hid-sensor-hub: Return error for hid_set_field() failure
Subsystems (3)
Srinivas Pandruvada
maintainerPATCH 1/2 HID: hid-sensor-hub: Return error for hid_set_field() failure
In the function sensor_hub_set_feature(), return error when hid_set_field() fails.
--- drivers/hid/hid-sensor-hub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/hid/hid-sensor-hub.c +9 -4
@@ -210,16 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, buffer_size = buffer_size /sizeof (__s32);if (buffer_size) {for (i =0 ; i < buffer_size; ++i) { -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (*buf32)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (*buf32)); +if (ret) + goto done_proc; + ++buf32; } }if (remaining_bytes) { value =0 ;memcpy (&value, (u8 *)buf32, remaining_bytes); -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (value)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (value)); +if (ret) + goto done_proc; }hid_hw_request (hsdev->hdev, report,HID_REQ_SET_REPORT );hid_hw_wait (hsdev->hdev);
Signature · 1 line
2.27.0
Srinivas Pandruvada
maintainerPATCH 2/2 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.
---
Replaces patch: HID: hid-sensor-custom: remove useless variable by Jiapeng Chong <[email protected]>
drivers/hid/hid-sensor-custom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-sensor-custom.c +2 -0
@@ -406,6 +406,8 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, report_id; ret =sensor_hub_set_feature (sensor_inst->hsdev, report_id, index,sizeof (value), &value); +if (ret) +return ret; }else return -EINVAL ;
Signature · 1 line
2.27.0
Jiri Kosina
maintainerRe: [PATCH 2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()
Quoted 17 lines · Srinivas Pandruvada
When user modifies a custom feature value and
sensor_hub_set_feature()fails, return error.Reported-by Abaci Robot <[email protected]>Signed-off-by Srinivas Pandruvada <[email protected]>---
Replaces patch: HID: hid-sensor-custom: remove useless variable by Jiapeng Chong <[email protected]>drivers/hid/hid-sensor-custom.c | 2 ++ 1 file changed, 2 insertions(+)drivers/hid/hid-sensor-custom.c +0
-0
drivers/hid/hid-sensor-custom.c static ssize_t store_value(struct device *dev, struct device_attribute *attr, · line 410
Quoted 5 lines
drivers/hid/hid-sensor-custom.c +2
-0@@ -406,6 +406,8 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, report_id; ret =sensor_hub_set_feature (sensor_inst->hsdev, report_id, index,sizeof (value), &value); +if (ret) +return ret;
What tree is this patch against? In my tree, we're not even assigning sensor_hub_set_feature() return value to anything.
Signature · 2 lines
Jiri Kosina SUSE Labs
Re: [PATCH 2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()
Quoted 15 lines · Jiri Kosina
Quoted 12 lines · Srinivas Pandruvada
When user modifies a custom feature value and
sensor_hub_set_feature()fails, return error.Reported-by Abaci Robot <[email protected]>Signed-off-by Srinivas Pandruvada <[email protected]>---
Replaces patch: HID: hid-sensor-custom: remove useless variable by Jiapeng Chong <[email protected]>drivers/hid/hid-sensor-custom.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 14 lines
drivers/hid/hid-sensor-custom.c static ssize_t store_value(struct device *dev, struct device_attribute *attr, · line 410
Quoted 10 lines
drivers/hid/hid-sensor-custom.c +2
-0@@ -406,6 +406,8 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, report_id; ret =sensor_hub_set_feature (sensor_inst->hsdev, report_id, index,sizeof (value), &value); +if (ret) +return ret;What tree is this patch against? In my tree, we're not even assigning
sensor_hub_set_feature()return value to anything.
I guess there was a "collision". At roughly the same time I merged
https://patchwork.kernel.org/project/linux-input/list/?series=456269
people were starting to send various patches for the same thing.
Srinivas, either the change in for-next (and probably Linus' master now) is fine, or could you rebase on top of hid.git?
Cheers,
Benjamin
Re: [PATCH 2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()
Hi Benjamin,
Quoted 39 lines · Benjamin Tissoires
Quoted 28 lines · Jiri Kosina
Quoted 25 lines · Srinivas Pandruvada
When user modifies a custom feature value and
sensor_hub_set_feature()
fails, return error.Reported-by Abaci Robot <[email protected]>Signed-off-by Srinivas Pandruvada <[email protected]>
---
Replaces patch: HID: hid-sensor-custom: remove useless variable by Jiapeng Chong <[email protected]>drivers/hid/hid-sensor-custom.c | 2 ++
1 file changed, 2 insertions(+)drivers/hid/hid- renamed from drivers/hid/hid-sensor-custom.c +0
-0
sensor-custom.c
index2628bc53ed80..58b54b127cdf100644drivers/hid/hid-sensor-custom.c +0
-0@@ -406,6 +406,8 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr,
report_id;
ret = sensor_hub_set_feature(sensor_inst->hsdev,report_id,Quoted 9 lines
Quoted 4 lines
index, sizeof(value), &value);
+ if (ret)
+ return ret;What tree is this patch against? In my tree, we're not even assigning
sensor_hub_set_feature()return value to anything.
Quoted 7 lines
I guess there was a "collision". At roughly the same time I merged
https://patchwork.kernel.org/project/linux-input/list/?series=456269
people were starting to send various patches for the same thing.Srinivas, either the change in for-next (and probably Linus' master now) is fine, or could you rebase on top of hid.git?
Rebased and attached based on top of the latest mainline.
Thanks,
Srinivas
Quoted 3 lines
Cheers,
Benjamin
From 461b85d5869bdc2da84df8aced8a181647082ea4 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <[email protected]>
Date: Thu, 15 Apr 2021 11:52:32 -0700
Subject: [UPDATED][PATCH 2/2] 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.
---
Updates:
Rebased on top of the latest mainline
drivers/hid/hid-sensor-custom.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hid/hid-sensor-custom.c +5 -3
@@ -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 ;
Signature · 1 line
2.27.0
Re: [PATCH 2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()
Quoted 1 line · Srinivas
Rebased and attached based on top of the latest mainline.
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs
Jonathan Cameron
maintainerQuoted 4 lines · On Thu, 15 Apr 2021 11:52:31 -0700 Srinivas Pandruvada…
In the function
sensor_hub_set_feature(), return error whenhid_set_field()fails.Signed-off-by Srinivas Pandruvada <[email protected]>
Series applied to the to greg branch of iio.git. Note these won't make the coming merge window, so will turn up in next sometime after rc1.
thanks,
Jonathan
Quoted 34 lines
--- drivers/hid/hid-sensor-hub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/hid/hid-sensor-hub.c +9
-4@@ -210,16 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, buffer_size = buffer_size /sizeof (__s32);if (buffer_size) {for (i =0 ; i < buffer_size; ++i) { -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (*buf32)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (*buf32)); +if (ret) + goto done_proc; + ++buf32; } }if (remaining_bytes) { value =0 ;memcpy (&value, (u8 *)buf32, remaining_bytes); -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (value)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (value)); +if (ret) + goto done_proc; }hid_hw_request (hsdev->hdev, report,HID_REQ_SET_REPORT );hid_hw_wait (hsdev->hdev);
Jonathan
Acked-by Jonathan CameronQuoted 9 lines · On Sun, 18 Apr 2021 12:12:44 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 4 lines · On Thu, 15 Apr 2021 11:52:31 -0700 Srinivas Pandruvada…
In the function
sensor_hub_set_feature(), return error whenhid_set_field()fails.Signed-off-by Srinivas Pandruvada <[email protected]>Series applied to the to greg branch of iio.git. Note these won't make the coming merge window, so will turn up in next sometime after rc1.
And dropped again. Not enough caffeine today. Not in IIO obviously so instead:
for both patches.
Quoted 40 lines
thanks,
Jonathan
Quoted 34 lines
--- drivers/hid/hid-sensor-hub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/hid/hid-sensor-hub.c +9
-4@@ -210,16 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, buffer_size = buffer_size /sizeof (__s32);if (buffer_size) {for (i =0 ; i < buffer_size; ++i) { -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (*buf32)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (*buf32)); +if (ret) + goto done_proc; + ++buf32; } }if (remaining_bytes) { value =0 ;memcpy (&value, (u8 *)buf32, remaining_bytes); -hid_set_field (report->field[field_index], i, - (__force __s32 )cpu_to_le32 (value)); + ret =hid_set_field (report->field[field_index], i, + (__force __s32 )cpu_to_le32 (value)); +if (ret) + goto done_proc; }hid_hw_request (hsdev->hdev, report,HID_REQ_SET_REPORT );hid_hw_wait (hsdev->hdev);
Quoted 4 lines · Srinivas Pandruvada
In the function
sensor_hub_set_feature(), return error whenhid_set_field()fails.Signed-off-by Srinivas Pandruvada <[email protected]>
Applied this one, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs