Skip to content

Commit cef9886

Browse files
ian-abbottgregkh
authored andcommitted
staging: comedi: comedi_fops: do not call blocking ops when !TASK_RUNNING
Comedi's read and write file operation handlers (`comedi_read()` and `comedi_write()`) currently call `copy_to_user()` or `copy_from_user()` whilst in the `TASK_INTERRUPTIBLE` state, which falls foul of the `might_fault()` checks when enabled. Fix it by setting the current task state back to `TASK_RUNNING` a bit earlier before calling these functions. Reported-by: Piotr Gregor <[email protected]> Signed-off-by: Ian Abbott <[email protected]> Cc: <[email protected]> # 4.5+ Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 055655a commit cef9886

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/staging/comedi/comedi_fops.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
23962396
continue;
23972397
}
23982398

2399+
set_current_state(TASK_RUNNING);
23992400
wp = async->buf_write_ptr;
24002401
n1 = min(n, async->prealloc_bufsz - wp);
24012402
n2 = n - n1;
@@ -2528,6 +2529,8 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
25282529
}
25292530
continue;
25302531
}
2532+
2533+
set_current_state(TASK_RUNNING);
25312534
rp = async->buf_read_ptr;
25322535
n1 = min(n, async->prealloc_bufsz - rp);
25332536
n2 = n - n1;

0 commit comments

Comments
 (0)