Skip to contentSkip to conversation

char: xillybus: Don't return -EFAULT on user-triggered flush

PATCH New Eli Billauer 1 participant 1 message Mar 27, 2015

Subsystems (2)
lore
Share & tools
lore

Eli Billauer

author maintainer
#0 lore raw

PATCH 1/1 char: xillybus: Don't return -EFAULT on user-triggered flush

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.

---
 drivers/char/xillybus/xillybus_core.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/char/xillybus/xillybus_core.c +2 -0
index b827fa0..77d6c12 100644
@@ -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;
 
Signature · 1 line
1.7.2.3