Commit 28e8190d authored by Markus Elfring's avatar Markus Elfring Committed by David S. Miller

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4825a4e4
...@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg) ...@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
} }
alen = ETH_ALEN * uf.count; alen = ETH_ALEN * uf.count;
addr = kmalloc(alen, GFP_KERNEL); addr = memdup_user(arg + sizeof(uf), alen);
if (!addr) if (IS_ERR(addr))
return -ENOMEM; return PTR_ERR(addr);
if (copy_from_user(addr, arg + sizeof(uf), alen)) {
err = -EFAULT;
goto done;
}
/* The filter is updated without holding any locks. Which is /* The filter is updated without holding any locks. Which is
* perfectly safe. We disable it first and in the worst * perfectly safe. We disable it first and in the worst
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment