Commit 9aae1aa6 authored by David S. Miller's avatar David S. Miller Committed by David S. Miller

[IPV6]: Memory leak found by stanford checker.

parent 5e6fff16
...@@ -127,8 +127,8 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr) ...@@ -127,8 +127,8 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
dev_hold(dev); dev_hold(dev);
dst_release(&rt->u.dst); dst_release(&rt->u.dst);
} else if (ishost) { } else if (ishost) {
sock_kfree_s(sk, pac, sizeof(*pac)); err = -EADDRNOTAVAIL;
return -EADDRNOTAVAIL; goto out_free_pac;
} else { } else {
/* router, no matching interface: just pick one */ /* router, no matching interface: just pick one */
...@@ -138,18 +138,17 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr) ...@@ -138,18 +138,17 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
dev = dev_get_by_index(ifindex); dev = dev_get_by_index(ifindex);
if (dev == NULL) { if (dev == NULL) {
sock_kfree_s(sk, pac, sizeof(*pac)); err = -ENODEV;
return -ENODEV; goto out_free_pac;
} }
idev = in6_dev_get(dev); idev = in6_dev_get(dev);
if (!idev) { if (!idev) {
sock_kfree_s(sk, pac, sizeof(*pac));
dev_put(dev);
if (ifindex) if (ifindex)
return -ENODEV; err = -ENODEV;
else else
return -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
goto out_dev_put;
} }
/* reset ishost, now that we have a specific device */ /* reset ishost, now that we have a specific device */
ishost = !idev->cnf.forwarding; ishost = !idev->cnf.forwarding;
...@@ -170,21 +169,17 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr) ...@@ -170,21 +169,17 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
err = -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
else if (!capable(CAP_NET_ADMIN)) else if (!capable(CAP_NET_ADMIN))
err = -EPERM; err = -EPERM;
if (err) { if (err)
sock_kfree_s(sk, pac, sizeof(*pac)); goto out_dev_put;
dev_put(dev);
return err;
}
} else if (!(ipv6_addr_type(addr) & IPV6_ADDR_ANYCAST) && } else if (!(ipv6_addr_type(addr) & IPV6_ADDR_ANYCAST) &&
!capable(CAP_NET_ADMIN)) !capable(CAP_NET_ADMIN)) {
return -EPERM; err = -EPERM;
goto out_dev_put;
}
err = ipv6_dev_ac_inc(dev, addr); err = ipv6_dev_ac_inc(dev, addr);
if (err) { if (err)
sock_kfree_s(sk, pac, sizeof(*pac)); goto out_dev_put;
dev_put(dev);
return err;
}
write_lock_bh(&ipv6_sk_ac_lock); write_lock_bh(&ipv6_sk_ac_lock);
pac->acl_next = np->ipv6_ac_list; pac->acl_next = np->ipv6_ac_list;
...@@ -194,6 +189,12 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr) ...@@ -194,6 +189,12 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
dev_put(dev); dev_put(dev);
return 0; return 0;
out_dev_put:
dev_put(dev);
out_free_pac:
sock_kfree_s(sk, pac, sizeof(*pac));
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