|
@@ -96,6 +96,7 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
|
|
}
|
|
}
|
|
|
|
|
|
kfree(list->buffer[list->tail].value);
|
|
kfree(list->buffer[list->tail].value);
|
|
|
|
+ list->buffer[list->tail].value = NULL;
|
|
list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1);
|
|
list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1);
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
@@ -300,6 +301,7 @@ static int hidraw_release(struct inode * inode, struct file * file)
|
|
struct hidraw *dev;
|
|
struct hidraw *dev;
|
|
struct hidraw_list *list = file->private_data;
|
|
struct hidraw_list *list = file->private_data;
|
|
int ret;
|
|
int ret;
|
|
|
|
+ int i;
|
|
|
|
|
|
mutex_lock(&minors_lock);
|
|
mutex_lock(&minors_lock);
|
|
if (!hidraw_table[minor]) {
|
|
if (!hidraw_table[minor]) {
|
|
@@ -317,6 +319,9 @@ static int hidraw_release(struct inode * inode, struct file * file)
|
|
kfree(list->hidraw);
|
|
kfree(list->hidraw);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < HIDRAW_BUFFER_SIZE; ++i)
|
|
|
|
+ kfree(list->buffer[i].value);
|
|
kfree(list);
|
|
kfree(list);
|
|
ret = 0;
|
|
ret = 0;
|
|
unlock:
|
|
unlock:
|
|
@@ -446,12 +451,17 @@ int hidraw_report_event(struct hid_device *hid, u8 *data, int len)
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
list_for_each_entry(list, &dev->list, node) {
|
|
list_for_each_entry(list, &dev->list, node) {
|
|
|
|
+ int new_head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
|
|
|
|
+
|
|
|
|
+ if (new_head == list->tail)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
if (!(list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC))) {
|
|
if (!(list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC))) {
|
|
ret = -ENOMEM;
|
|
ret = -ENOMEM;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
list->buffer[list->head].len = len;
|
|
list->buffer[list->head].len = len;
|
|
- list->head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
|
|
|
|
|
|
+ list->head = new_head;
|
|
kill_fasync(&list->fasync, SIGIO, POLL_IN);
|
|
kill_fasync(&list->fasync, SIGIO, POLL_IN);
|
|
}
|
|
}
|
|
|
|
|