diff mbox series

[2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature()

Message ID 20210415185232.2617398-2-srinivas.pandruvada@linux.intel.com
State New
Headers show
Series None | expand

Commit Message

Srinivas Pandruvada April 15, 2021, 6:52 p.m. UTC
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>
---
Replaces patch: HID: hid-sensor-custom: remove useless variable
by Jiapeng Chong <jiapeng.chong@linux.alibaba.com> 

 drivers/hid/hid-sensor-custom.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jiri Kosina May 5, 2021, 12:38 p.m. UTC | #1
On Thu, 15 Apr 2021, Srinivas Pandruvada wrote:

> 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>

> ---

> Replaces patch: HID: hid-sensor-custom: remove useless variable

> by Jiapeng Chong <jiapeng.chong@linux.alibaba.com> 

> 

>  drivers/hid/hid-sensor-custom.c | 2 ++

>  1 file changed, 2 insertions(+)

> 

> diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c

> index 2628bc53ed80..58b54b127cdf 100644

> --- a/drivers/hid/hid-sensor-custom.c

> +++ b/drivers/hid/hid-sensor-custom.c

> @@ -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.

-- 
Jiri Kosina
SUSE Labs
Benjamin Tissoires May 5, 2021, 1:28 p.m. UTC | #2
On Wed, May 5, 2021 at 2:38 PM Jiri Kosina <jikos@kernel.org> wrote:
>

> On Thu, 15 Apr 2021, Srinivas Pandruvada wrote:

>

> > 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>

> > ---

> > Replaces patch: HID: hid-sensor-custom: remove useless variable

> > by Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

> >

> >  drivers/hid/hid-sensor-custom.c | 2 ++

> >  1 file changed, 2 insertions(+)

> >

> > diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c

> > index 2628bc53ed80..58b54b127cdf 100644

> > --- a/drivers/hid/hid-sensor-custom.c

> > +++ b/drivers/hid/hid-sensor-custom.c

> > @@ -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
Pandruvada, Srinivas May 6, 2021, 4:44 a.m. UTC | #3
Hi Benjamin,

On Wed, 2021-05-05 at 15:28 +0200, Benjamin Tissoires wrote:
> On Wed, May 5, 2021 at 2:38 PM Jiri Kosina <jikos@kernel.org> wrote:

> > 

> > On Thu, 15 Apr 2021, Srinivas Pandruvada wrote:

> > 

> > > 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>

> > > ---

> > > Replaces patch: HID: hid-sensor-custom: remove useless variable

> > > by Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

> > > 

> > >  drivers/hid/hid-sensor-custom.c | 2 ++

> > >  1 file changed, 2 insertions(+)

> > > 

> > > diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-

> > > sensor-custom.c

> > > index 2628bc53ed80..58b54b127cdf 100644

> > > --- a/drivers/hid/hid-sensor-custom.c

> > > +++ b/drivers/hid/hid-sensor-custom.c

> > > @@ -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?

> 


Rebased and attached based on top of the latest mainline.

Thanks,
Srinivas


> Cheers,

> Benjamin

>
From 461b85d5869bdc2da84df8aced8a181647082ea4 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
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.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
Updates:
	Rebased on top of the latest mainline

 drivers/hid/hid-sensor-custom.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 2e6662173a79..32c2306e240d 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -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;
Jiri Kosina May 13, 2021, 11 a.m. UTC | #4
On Thu, 6 May 2021, Pandruvada, Srinivas wrote:

> Rebased and attached based on top of the latest mainline.


Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
diff mbox series

Patch

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 2628bc53ed80..58b54b127cdf 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -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;