Skip to content

Commit eb83174

Browse files
arndbgregkh
authored andcommitted
char: nwbutton: open-code interruptible_sleep_on
The nwbutton driver uses interruptible_sleep_on to wait for buttons getting pressed after we enter the read() function, which is inherently racy and cannot be fixed by using wait_event without changing the driver's user space interface. Instead, this patch just uses an open-coded variant of the same interruptible_sleep_on() call, so the driver behavior doesn't change but we remove the sleep_on family from the kernel. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 83ce074 commit eb83174

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/char/nwbutton.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ static irqreturn_t button_handler (int irq, void *dev_id)
168168
static int button_read (struct file *filp, char __user *buffer,
169169
size_t count, loff_t *ppos)
170170
{
171-
interruptible_sleep_on (&button_wait_queue);
171+
DEFINE_WAIT(wait);
172+
prepare_to_wait(&button_wait_queue, &wait, TASK_INTERRUPTIBLE);
173+
schedule();
174+
finish_wait(&button_wait_queue, &wait);
172175
return (copy_to_user (buffer, &button_output_buffer, bcount))
173176
? -EFAULT : bcount;
174177
}

0 commit comments

Comments
 (0)