From patchwork Tue Apr 8 05:04:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 3947771 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6548ABFF02 for ; Tue, 8 Apr 2014 05:04:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A10B6201D5 for ; Tue, 8 Apr 2014 05:04:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9E5A201CE for ; Tue, 8 Apr 2014 05:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750868AbaDHFEY (ORCPT ); Tue, 8 Apr 2014 01:04:24 -0400 Received: from mail-pb0-f49.google.com ([209.85.160.49]:49865 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbaDHFEY (ORCPT ); Tue, 8 Apr 2014 01:04:24 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so485226pbb.22 for ; Mon, 07 Apr 2014 22:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=hR1TQQI/O4D4HzBSpCL9LFwgWrLotVSu7gpF4CKAKcc=; b=ySZ2tdTyN/fz2Vsaa28SPqHJpc0wF2ZSorOIGMWku9oLHO/hW4G8nnRnWVDbxHtUw/ S5tzRrs61Y+1SlOYFYy8WsxQOWcg5WNntVEf8Wq8IDYy66rlI7AzubuvwAzORhSCbQ5v v8MFnTfC5m7p9wx6bfyMhCX5AgIYYO/hHlemM3DMfQq3zm+f12we79/qwHFIoKLKS6v/ 6nf4i53drFUpwkyManRI6rOM5/rfH5fnkjx0/goVOcmAu1LMcXGdVVgItNXqbR7cQgw/ 57BLSwH6riGk/2VxjQWR89I+pjsafMzKd0pahImMTf16j5zrDfu8vwlsAtc7XLi1wwyG vozQ== X-Received: by 10.68.134.169 with SMTP id pl9mr1775437pbb.133.1396933463824; Mon, 07 Apr 2014 22:04:23 -0700 (PDT) Received: from [192.168.0.104] ([118.117.108.102]) by mx.google.com with ESMTPSA id pr4sm1668492pbb.53.2014.04.07.22.04.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 22:04:22 -0700 (PDT) Message-ID: <53438341.5090705@gmail.com> Date: Tue, 08 Apr 2014 13:04:01 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: "J. Bruce Fields" , linux-nfs@vger.kernel.org Subject: [PATCH] NFSD: Use simple_read_from_buffer for coping data to userspace Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Kinglong Mee --- fs/nfsd/fault_inject.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) static ssize_t fault_inject_write(struct file *file, const char __user *buf, diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index d620e7f..2ed05c3 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c @@ -97,25 +97,14 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf, { static u64 val; char read_buf[25]; - size_t size, ret; + size_t size; loff_t pos = *ppos; if (!pos) nfsd_inject_get(file_inode(file)->i_private, &val); size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val); - if (pos < 0) - return -EINVAL; - if (pos >= size || !len) - return 0; - if (len > size - pos) - len = size - pos; - ret = copy_to_user(buf, read_buf + pos, len); - if (ret == len) - return -EFAULT; - len -= ret; - *ppos = pos + len; - return len; + return simple_read_from_buffer(buf, len, ppos, read_buf, size); }