From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbbC0JP7 (ORCPT ); Fri, 27 Mar 2015 05:15:59 -0400 Received: from aso-006-i440.relay.mailchannels.net ([23.91.64.121]:23454 "EHLO relay.mailchannels.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752655AbbC0JP4 (ORCPT ); Fri, 27 Mar 2015 05:15:56 -0400 X-Greylist: delayed 1158 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Mar 2015 05:15:55 EDT X-Sender-Id: totalchoicehosting|x-authuser|billaue X-Sender-Id: totalchoicehosting|x-authuser|billaue X-MC-Relay: Neutral X-MailChannels-SenderId: totalchoicehosting|x-authuser|billaue X-MailChannels-Auth-Id: totalchoicehosting X-MC-Loop-Signature: 1427446595490:677232160 X-MC-Ingress-Time: 1427446595490 From: Eli Billauer To: arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Eli Billauer Subject: [PATCH] char: xillybus: Don't return -EFAULT on user-triggered flush Date: Fri, 27 Mar 2015 11:56:06 +0300 Message-Id: <1427446566-17606-1-git-send-email-eli.billauer@gmail.com> X-Mailer: git-send-email 1.7.2.3 X-AuthUser: billaue Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/char/xillybus/xillybus_core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c index b827fa0..77d6c12 100644 --- a/drivers/char/xillybus/xillybus_core.c +++ b/drivers/char/xillybus/xillybus_core.c @@ -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; -- 1.7.2.3