Skip to content

Commit

Permalink
HID: avoid '\0' in hid debugfs events file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bruno Prémont authored and Jiri Kosina committed Mar 16, 2010
1 parent 3ee8f0a commit e639ba4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/hid/hid-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ void hid_debug_event(struct hid_device *hdev, char *buf)
struct hid_debug_list *list;

list_for_each_entry(list, &hdev->debug_list, node) {
for (i = 0; i <= strlen(buf); i++)
list->hid_debug_buf[(list->tail + i) % (HID_DEBUG_BUFSIZE - 1)] =
for (i = 0; i < strlen(buf); i++)
list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
buf[i];
list->tail = (list->tail + i) % (HID_DEBUG_BUFSIZE - 1);
list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
}
}
EXPORT_SYMBOL_GPL(hid_debug_event);
Expand Down

0 comments on commit e639ba4

Please sign in to comment.