summaryrefslogtreecommitdiff
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-20 08:54:15 +0200
committerDavid S. Miller <davem@davemloft.net>2016-08-20 19:11:33 -0700
commit28e8190d2fb3918b5d46acafeb1968cd26e30dad (patch)
tree125705e420781a355423c14d6c159f21e059612d /drivers/net/tun.c
parent4825a4e42c7e61520038c7d7d3efb4ffbbbd7091 (diff)
tun: Use memdup_user() rather than duplicating its implementation
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>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 9c8b5bc2b9d8..a1aeccbce6d4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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