Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 229eed43 authored by Geyslan G. Bem's avatar Geyslan G. Bem Committed by Chris Mason
Browse files

btrfs: simplify kmalloc+copy_from_user to memdup_user

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: default avatarGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 5ede859b
Loading
Loading
Loading
Loading
+3 −8
Original line number Original line Diff line number Diff line
@@ -2715,15 +2715,10 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
	size = sizeof(tmp) +
	size = sizeof(tmp) +
		tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info);
		tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info);


	same = kmalloc(size, GFP_NOFS);
	same = memdup_user((struct btrfs_ioctl_same_args __user *)argp, size);
	if (!same) {
		ret = -EFAULT;
		goto out;
	}


	if (copy_from_user(same,
	if (IS_ERR(same)) {
			   (struct btrfs_ioctl_same_args __user *)argp, size)) {
		ret = PTR_ERR(same);
		ret = -EFAULT;
		goto out;
		goto out;
	}
	}