Skip to content

Commit

Permalink
tun: Use memdup_user() rather than duplicating its implementation
Browse files Browse the repository at this point in the history
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Markus Elfring authored and David S. Miller committed Aug 21, 2016
1 parent 4825a4e commit 28e8190
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
}

alen = ETH_ALEN * uf.count;
addr = kmalloc(alen, GFP_KERNEL);
if (!addr)
return -ENOMEM;

if (copy_from_user(addr, arg + sizeof(uf), alen)) {
err = -EFAULT;
goto done;
}
addr = memdup_user(arg + sizeof(uf), alen);
if (IS_ERR(addr))
return PTR_ERR(addr);

/* The filter is updated without holding any locks. Which is
* perfectly safe. We disable it first and in the worst
Expand Down

0 comments on commit 28e8190

Please sign in to comment.