소스 검색

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>
Jiri Kosina 16 년 전
부모
커밋
55dba52458
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      drivers/hid/hid-core.c

+ 3 - 1
drivers/hid/hid-core.c

@@ -1100,8 +1100,10 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
 	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,