public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: vandrove@vc.cvut.cz, LKML <linux-kernel@vger.kernel.org>,
	linware@sh.cvut.cz
Subject: [PATCH 5/6] ncpfs: use memdup_user()
Date: Wed, 08 Apr 2009 15:08:53 +0800	[thread overview]
Message-ID: <49DC4D85.5000205@cn.fujitsu.com> (raw)
In-Reply-To: <49DC4CC0.9050805@cn.fujitsu.com>

Remove open-coded memdup_user()

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/ncpfs/ioctl.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index f54360f..fa038df 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -660,13 +660,10 @@ outrel:
 			if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
 				return -ENOMEM;
 			if (user.object_name_len) {
-				newname = kmalloc(user.object_name_len, GFP_USER);
-				if (!newname)
-					return -ENOMEM;
-				if (copy_from_user(newname, user.object_name, user.object_name_len)) {
-					kfree(newname);
-					return -EFAULT;
-				}
+				newname = memdup_user(user.object_name,
+						      user.object_name_len);
+				if (IS_ERR(newname))
+					return PTR_ERR(newname);
 			} else {
 				newname = NULL;
 			}
@@ -760,13 +757,9 @@ outrel:
 			if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
 				return -ENOMEM;
 			if (user.len) {
-				new = kmalloc(user.len, GFP_USER);
-				if (!new)
-					return -ENOMEM;
-				if (copy_from_user(new, user.data, user.len)) {
-					kfree(new);
-					return -EFAULT;
-				}
+				new = memdup_user(user.data, user.len);
+				if (IS_ERR(new))
+					return PTR_ERR(new);
 			} else {
 				new = NULL;
 			}
-- 
1.5.4.rc3



  parent reply	other threads:[~2009-04-08  7:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08  7:05 [PATCH 0/6] fs: use memdup_user() Li Zefan
2009-04-08  7:06 ` [PATCH 1/6] xattr: " Li Zefan
2009-04-08  7:06 ` [PATCH 2/6] btrfs: " Li Zefan
2009-04-08  7:07 ` [PATCH 3/6] sysfs: " Li Zefan
2009-04-08  7:08 ` [PATCH 4/6] xfs: " Li Zefan
2009-04-08 13:22   ` Christoph Hellwig
2009-04-08 17:31     ` Roland Dreier
2009-04-09  0:43       ` Li Zefan
2009-04-08 20:06     ` Felix Blyakher
2009-04-08  7:08 ` Li Zefan [this message]
2009-04-08  7:09 ` [PATCH 6/6] ecryptfs: " Li Zefan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49DC4D85.5000205@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linware@sh.cvut.cz \
    --cc=vandrove@vc.cvut.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox