Commit 242afaa6 authored by David Ahern's avatar David Ahern Committed by David S. Miller

net/ipv6: Put target net when address dump fails due to bad attributes

If tgt_net is set based on IFA_TARGET_NETNSID attribute in the dump
request, make sure all error paths call put_net.

Fixes: 6371a71f ("net/ipv6: Add support for dumping addresses for a specific device")
Fixes: ed6eff11 ("net/ipv6: Update inet6_dump_addr for strict data checking")
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d7e38611
...@@ -5089,23 +5089,25 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -5089,23 +5089,25 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev; struct net_device *dev;
struct inet6_dev *idev; struct inet6_dev *idev;
struct hlist_head *head; struct hlist_head *head;
int err = 0;
s_h = cb->args[0]; s_h = cb->args[0];
s_idx = idx = cb->args[1]; s_idx = idx = cb->args[1];
s_ip_idx = cb->args[2]; s_ip_idx = cb->args[2];
if (cb->strict_check) { if (cb->strict_check) {
int err;
err = inet6_valid_dump_ifaddr_req(nlh, &fillargs, &tgt_net, err = inet6_valid_dump_ifaddr_req(nlh, &fillargs, &tgt_net,
skb->sk, cb); skb->sk, cb);
if (err < 0) if (err < 0)
return err; goto put_tgt_net;
err = 0;
if (fillargs.ifindex) { if (fillargs.ifindex) {
dev = __dev_get_by_index(tgt_net, fillargs.ifindex); dev = __dev_get_by_index(tgt_net, fillargs.ifindex);
if (!dev) if (!dev) {
return -ENODEV; err = -ENODEV;
goto put_tgt_net;
}
idev = __in6_dev_get(dev); idev = __in6_dev_get(dev);
if (idev) { if (idev) {
err = in6_dump_addrs(idev, skb, cb, s_ip_idx, err = in6_dump_addrs(idev, skb, cb, s_ip_idx,
...@@ -5144,7 +5146,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -5144,7 +5146,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
if (fillargs.netnsid >= 0) if (fillargs.netnsid >= 0)
put_net(tgt_net); put_net(tgt_net);
return skb->len; return err < 0 ? err : skb->len;
} }
static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
......
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