HID: fix memory leak on error path in debug code
If hid_get_report() fails, we forgot to free the already allocated buffer
for debugging messages on error path. Fix that up.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 449bd74..86c2ff2 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1100,8 +1100,10 @@
hid_debug_event(hid, buf);
report = hid_get_report(report_enum, data);
- if (!report)
+ if (!report) {
+ kfree(buf);
return -1;
+ }
/* dump the report */
snprintf(buf, HID_DEBUG_BUFSIZE - 1,