Commit 8238ac0c authored by David S. Miller's avatar David S. Miller

Merge branch 'tun-cleanups'

Markus Elfring says:

====================
tun: Fine-tuning for update_filter()

A few update suggestions were taken into account
from static source code analysis.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4825a4e4 3b8d2a69
...@@ -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
...@@ -758,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg) ...@@ -758,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
for (; n < uf.count; n++) { for (; n < uf.count; n++) {
if (!is_multicast_ether_addr(addr[n].u)) { if (!is_multicast_ether_addr(addr[n].u)) {
err = 0; /* no filter */ err = 0; /* no filter */
goto done; goto free_addr;
} }
addr_hash_set(filter->mask, addr[n].u); addr_hash_set(filter->mask, addr[n].u);
} }
...@@ -774,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg) ...@@ -774,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
/* Return the number of exact filters */ /* Return the number of exact filters */
err = nexact; err = nexact;
free_addr:
done:
kfree(addr); kfree(addr);
return err; return err;
} }
......
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