aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Prémont <bonbons@linux-vserver.org>2010-03-15 14:00:27 -0400
committerJiri Kosina <jkosina@suse.cz>2010-03-16 08:36:01 -0400
commite639ba481b76e445df354acd6e29d859a9b1657f (patch)
tree5c10ca02dfff40acb1dc5c1915669a8c31e818a9
parent3ee8f0a2b1c81f0472b25d40aa5c1c7c6a0edc2a (diff)
HID: avoid '\0' in hid debugfs events file
When dumping /sys/kernel/debug/hid/$device/events '\0' characters show up (invisible if cat to console but shown by less or while looking at a dump file). These are due to hid_debug_event() adding strlen()+1 bytes to the ring buffer (e.g. including the trailing '\0'). Any roll-over causes a '\0' as well as hid_debug_event() handles the ring buffers with HID_DEBUG_BUFSIZE-1 size while hid_debug_events_read() handles it with full HID_DEBUG_BUFSIZE size. Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-debug.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index cd4ece6fdfb9..0c4e75573186 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -564,10 +564,10 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
564 struct hid_debug_list *list; 564 struct hid_debug_list *list;
565 565
566 list_for_each_entry(list, &hdev->debug_list, node) { 566 list_for_each_entry(list, &hdev->debug_list, node) {
567 for (i = 0; i <= strlen(buf); i++) 567 for (i = 0; i < strlen(buf); i++)
568 list->hid_debug_buf[(list->tail + i) % (HID_DEBUG_BUFSIZE - 1)] = 568 list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
569 buf[i]; 569 buf[i];
570 list->tail = (list->tail + i) % (HID_DEBUG_BUFSIZE - 1); 570 list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
571 } 571 }
572} 572}
573EXPORT_SYMBOL_GPL(hid_debug_event); 573EXPORT_SYMBOL_GPL(hid_debug_event);