* [PATCH] btrfs: simplify kmalloc+copy_from_user to memdup_user
@ 2013-10-14 15:18 Geyslan G. Bem
0 siblings, 0 replies; 2+ messages in thread
From: Geyslan G. Bem @ 2013-10-14 15:18 UTC (permalink / raw)
To: chris.mason; +Cc: linux-btrfs, linux-kernel, kernel-br, Geyslan G. Bem
Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives
The semantic patch that makes this report is available
in scripts/coccinelle/api/memdup_user.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
fs/btrfs/ioctl.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9d46f60..f0e3517 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2727,15 +2727,10 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
size = sizeof(tmp) +
tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info);
- same = kmalloc(size, GFP_NOFS);
- if (!same) {
- ret = -EFAULT;
- goto out;
- }
+ same = memdup_user((struct btrfs_ioctl_same_args __user *)argp, size);
- if (copy_from_user(same,
- (struct btrfs_ioctl_same_args __user *)argp, size)) {
- ret = -EFAULT;
+ if (IS_ERR(same)) {
+ ret = PTR_ERR(same);
goto out;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] btrfs: simplify kmalloc+copy_from_user to memdup_user
@ 2013-10-14 15:14 Geyslan G. Bem
0 siblings, 0 replies; 2+ messages in thread
From: Geyslan G. Bem @ 2013-10-14 15:14 UTC (permalink / raw)
To: chris.mason; +Cc: linux-btrfs, linux-kernel, kernel-br, Geyslan G. Bem
Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives
The semantic patch that makes this report is available
in scripts/coccinelle/api/memdup_user.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
fs/btrfs/ioctl.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9d46f60..f0e3517 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2727,15 +2727,10 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
size = sizeof(tmp) +
tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info);
- same = kmalloc(size, GFP_NOFS);
- if (!same) {
- ret = -EFAULT;
- goto out;
- }
+ same = memdup_user((struct btrfs_ioctl_same_args __user *)argp, size);
- if (copy_from_user(same,
- (struct btrfs_ioctl_same_args __user *)argp, size)) {
- ret = -EFAULT;
+ if (IS_ERR(same)) {
+ ret = PTR_ERR(same);
goto out;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-14 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14 15:18 [PATCH] btrfs: simplify kmalloc+copy_from_user to memdup_user Geyslan G. Bem
-- strict thread matches above, loose matches on Subject: below --
2013-10-14 15:14 Geyslan G. Bem
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).