Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0e14951 authored by Jiri Kosina's avatar Jiri Kosina
Browse files

HID: fix possible deadlock in hidraw_read



If the loop in hidraw_read() loops more than once, then we might
end up trying to acquire already locked mutex, casuing a deadlock.

Reported-by: default avatariceberg <iceberg@ispras.ru>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent ff9b00a2
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -47,10 +47,9 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
	char *report;
	DECLARE_WAITQUEUE(wait, current);

	while (ret == 0) {

	mutex_lock(&list->read_mutex);

	while (ret == 0) {
		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);