linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: Fix return value in hid-core.c
@ 2012-09-14 11:46 Sachin Kamat
  2012-09-17 11:02 ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Sachin Kamat @ 2012-09-14 11:46 UTC (permalink / raw)
  To: linux-input; +Cc: jkosina, sachin.kamat, patches

Return -ENOMEM instead of -1 if memory allocation fails.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/hid/hid-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 16d6454..1011a22 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 				parser->device->collection_size * 2, GFP_KERNEL);
 		if (collection == NULL) {
 			hid_err(parser->device, "failed to reallocate collection array\n");
-			return -1;
+			return -ENOMEM;
 		}
 		memcpy(collection, parser->device->collection,
 			sizeof(struct hid_collection) *
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: Fix return value in hid-core.c
  2012-09-14 11:46 [PATCH] HID: Fix return value in hid-core.c Sachin Kamat
@ 2012-09-17 11:02 ` Jiri Kosina
  2012-09-17 11:11   ` Sachin Kamat
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2012-09-17 11:02 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-input, patches

On Fri, 14 Sep 2012, Sachin Kamat wrote:

> Return -ENOMEM instead of -1 if memory allocation fails.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/hid/hid-core.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 16d6454..1011a22 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
>  				parser->device->collection_size * 2, GFP_KERNEL);
>  		if (collection == NULL) {
>  			hid_err(parser->device, "failed to reallocate collection array\n");
> -			return -1;
> +			return -ENOMEM;

While you are at it, could you please update the return value in case the 
collection stack overflows? I'd go with EINVAL. Thanks.

>  		}
>  		memcpy(collection, parser->device->collection,
>  			sizeof(struct hid_collection) *
> -- 
> 1.7.4.1
> 

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: Fix return value in hid-core.c
  2012-09-17 11:02 ` Jiri Kosina
@ 2012-09-17 11:11   ` Sachin Kamat
  0 siblings, 0 replies; 3+ messages in thread
From: Sachin Kamat @ 2012-09-17 11:11 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, patches

On 17 September 2012 16:32, Jiri Kosina <jkosina@suse.cz> wrote:
> On Fri, 14 Sep 2012, Sachin Kamat wrote:
>
>> Return -ENOMEM instead of -1 if memory allocation fails.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/hid/hid-core.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
>> index 16d6454..1011a22 100644
>> --- a/drivers/hid/hid-core.c
>> +++ b/drivers/hid/hid-core.c
>> @@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
>>                               parser->device->collection_size * 2, GFP_KERNEL);
>>               if (collection == NULL) {
>>                       hid_err(parser->device, "failed to reallocate collection array\n");
>> -                     return -1;
>> +                     return -ENOMEM;
>
> While you are at it, could you please update the return value in case the
> collection stack overflows? I'd go with EINVAL. Thanks.

Sure. I will update and re-send the patch.

>
>>               }
>>               memcpy(collection, parser->device->collection,
>>                       sizeof(struct hid_collection) *
>> --
>> 1.7.4.1
>>
>
> --
> Jiri Kosina
> SUSE Labs



-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-17 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 11:46 [PATCH] HID: Fix return value in hid-core.c Sachin Kamat
2012-09-17 11:02 ` Jiri Kosina
2012-09-17 11:11   ` Sachin Kamat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).