Skip to content

Commit

Permalink
char: xillybus: Don't return -EFAULT on user-triggered flush
Browse files Browse the repository at this point in the history
The API allows the application to flush a host-to-FPGA stream by calling
write() with the data count set to zero. Before this patch, copy_from_user()
was called with a non-zero byte count, which possibly made it attempt to read
from unmapped user memory. Such attempts caused the driver to return -EFAULT
instead of 0, even though the desired operation went through fine.

This patch ensures the driver returns 0 on a successful flush.

Signed-off-by: Eli Billauer <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
billauer authored and gregkh committed Apr 3, 2015
1 parent be29bc2 commit 127af88
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/char/xillybus/xillybus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,8 @@ static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
unsigned char *tail;
int i;

howmany = 0;

end_offset_plus1 = bufpos >>
channel->log2_element_size;

Expand Down

0 comments on commit 127af88

Please sign in to comment.