diff options
| author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-09-17 07:11:56 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2012-09-17 07:15:55 -0400 |
| commit | a6fbaacfb990580c080e4fad6623b7108f5a0507 (patch) | |
| tree | 85ac2fbf6ce62d686006c91dce792325eaea9212 /drivers | |
| parent | 832fbeaef446a7024c5e0f19b7122100a7b1003d (diff) | |
HID: Fix return values in open_collection()
Return -ENOMEM instead of -1 if memory allocation fails.
Return -EINVAL instead of -1 for stack overflow and
underflow errors.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hid/hid-core.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8d3946af9ff6..62333e9dcb3a 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -126,7 +126,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) | |||
| 126 | 126 | ||
| 127 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { | 127 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { |
| 128 | hid_err(parser->device, "collection stack overflow\n"); | 128 | hid_err(parser->device, "collection stack overflow\n"); |
| 129 | return -1; | 129 | return -EINVAL; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | if (parser->device->maxcollection == parser->device->collection_size) { | 132 | if (parser->device->maxcollection == parser->device->collection_size) { |
| @@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) | |||
| 134 | parser->device->collection_size * 2, GFP_KERNEL); | 134 | parser->device->collection_size * 2, GFP_KERNEL); |
| 135 | if (collection == NULL) { | 135 | if (collection == NULL) { |
| 136 | hid_err(parser->device, "failed to reallocate collection array\n"); | 136 | hid_err(parser->device, "failed to reallocate collection array\n"); |
| 137 | return -1; | 137 | return -ENOMEM; |
| 138 | } | 138 | } |
| 139 | memcpy(collection, parser->device->collection, | 139 | memcpy(collection, parser->device->collection, |
| 140 | sizeof(struct hid_collection) * | 140 | sizeof(struct hid_collection) * |
| @@ -170,7 +170,7 @@ static int close_collection(struct hid_parser *parser) | |||
| 170 | { | 170 | { |
| 171 | if (!parser->collection_stack_ptr) { | 171 | if (!parser->collection_stack_ptr) { |
| 172 | hid_err(parser->device, "collection stack underflow\n"); | 172 | hid_err(parser->device, "collection stack underflow\n"); |
| 173 | return -1; | 173 | return -EINVAL; |
| 174 | } | 174 | } |
| 175 | parser->collection_stack_ptr--; | 175 | parser->collection_stack_ptr--; |
| 176 | return 0; | 176 | return 0; |
