Skip to content

Commit

Permalink
HID: simplify error handling in hid_input_report()
Browse files Browse the repository at this point in the history
The handling of failed debugging buffer allocation got overly
complicated. We simply want to skip the debugging code if allocation
fails and go on with event processing.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Jiri Kosina committed Mar 18, 2010
1 parent 1caea61 commit f77e347
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,8 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i

buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);

if (!buf) {
report = hid_get_report(report_enum, data);
if (!buf)
goto nomem;
}

/* dump the report */
snprintf(buf, HID_DEBUG_BUFSIZE - 1,
Expand All @@ -1107,17 +1105,14 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
hid_debug_event(hid, buf);
}
hid_debug_event(hid, "\n");
kfree(buf);

nomem:
report = hid_get_report(report_enum, data);

if (!report) {
kfree(buf);
if (!report)
return -1;
}

kfree(buf);

nomem:
if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
ret = hdrv->raw_event(hid, report, data, size);
if (ret != 0)
Expand Down

0 comments on commit f77e347

Please sign in to comment.