Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1575994

[PATCH 02/18] HID: Delete an error message for a failed memory allocation in open_collection()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 02/18] HID: Delete an error message for a failed memory allocation in open_collection()
Date 2017-02-07 20:50 +0100
Message-ID <t8jW2-74w-37@gated-at.bofh.it> (permalink)
References <t8jMm-70G-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 18:42:26 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9b0a97bbde96..ffb7e5d4ee19 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -133,10 +133,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 	if (parser->device->maxcollection == parser->device->collection_size) {
 		collection = kmalloc(sizeof(struct hid_collection) *
 				parser->device->collection_size * 2, GFP_KERNEL);
-		if (collection == NULL) {
-			hid_err(parser->device, "failed to reallocate collection array\n");
+		if (!collection)
 			return -ENOMEM;
-		}
+
 		memcpy(collection, parser->device->collection,
 			sizeof(struct hid_collection) *
 			parser->device->collection_size);
-- 
2.11.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/18] HID: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:40 +0100
  [PATCH 06/18] HID: Improve another size determination in  hid_scan_report() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 07/18] HID: Improve another size determination in  hid_register_report() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 04/18] HID: Improve another size determination in  open_collection() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 03/18] HID: Use kmalloc_array() in open_collection() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 05/18] HID: Improve two size determinations in  hid_open_report() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 01/18] HID: Use kmalloc_array() in hid_input_field() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 02/18] HID: Delete an error message for a failed memory  allocation in open_collection() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 20:50 +0100
  [PATCH 09/18] HID: Return an error code only as a constant in  hid_allocate_device() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:00 +0100
  [PATCH 08/18] HID: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:00 +0100
  [PATCH 11/18] HID-debug: Delete an unnecessary seq_printf() call in  hid_dump_device() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:00 +0100
  [PATCH 12/18] HID-debug: Replace 12 seq_printf() calls by seq_puts() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:00 +0100
  [PATCH 10/18] HID-debug: Replace five seq_printf() calls by  seq_putc() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:00 +0100
  [PATCH 16/18] HID-debug: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100
  [PATCH 18/18] HID-picoLCD: Use seq_puts() in  picolcd_debug_reset_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100
  [PATCH 15/18] HID-debug: Return an error code only as a constant in  hid_debug_events_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100
  [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call  in hid_dump_field() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100
    Re: [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one  call in hid_dump_field() Joe Perches <joe@perches.com> - 2017-02-08 00:00 +0100
  [PATCH 14/18] HID-debug: Adjust two function calls together with a  variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100
  [PATCH 17/18] HID-debug: Delete an unnecessary variable  initialisation in hid_resolv_usage() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-07 21:10 +0100

csiph-web