Commit 50b2abed authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net:
  packet: fix possible dev refcnt leak when bind fail
  netem: dont call vfree() under spinlock and BH disabled
  netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded
  netfilter: ctnetlink: fix return value of ctnetlink_get_expect()
parents 7578ed02 aef950b4
...@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone, ...@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
nf_ct_protonum(ct)); nf_ct_protonum(ct));
if (helper == NULL) { if (helper == NULL) {
rcu_read_unlock(); rcu_read_unlock();
spin_unlock_bh(&nf_conntrack_lock);
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
if (request_module("nfct-helper-%s", helpname) < 0) { if (request_module("nfct-helper-%s", helpname) < 0) {
spin_lock_bh(&nf_conntrack_lock);
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto err1; goto err1;
} }
spin_lock_bh(&nf_conntrack_lock);
rcu_read_lock(); rcu_read_lock();
helper = __nf_conntrack_helper_find(helpname, helper = __nf_conntrack_helper_find(helpname,
nf_ct_l3num(ct), nf_ct_l3num(ct),
...@@ -1869,25 +1872,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, ...@@ -1869,25 +1872,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
err = -ENOMEM; err = -ENOMEM;
skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (skb2 == NULL) if (skb2 == NULL) {
nf_ct_expect_put(exp);
goto out; goto out;
}
rcu_read_lock(); rcu_read_lock();
err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp); nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp);
rcu_read_unlock(); rcu_read_unlock();
nf_ct_expect_put(exp);
if (err <= 0) if (err <= 0)
goto free; goto free;
nf_ct_expect_put(exp); err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
if (err < 0)
goto out;
return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); return 0;
free: free:
kfree_skb(skb2); kfree_skb(skb2);
out: out:
nf_ct_expect_put(exp); /* this avoids a loop in nfnetlink. */
return err; return err == -EAGAIN ? -ENOBUFS : err;
} }
static int static int
......
...@@ -2448,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc ...@@ -2448,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
{ {
struct packet_sock *po = pkt_sk(sk); struct packet_sock *po = pkt_sk(sk);
if (po->fanout) if (po->fanout) {
if (dev)
dev_put(dev);
return -EINVAL; return -EINVAL;
}
lock_sock(sk); lock_sock(sk);
......
...@@ -488,7 +488,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) ...@@ -488,7 +488,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
return -EINVAL; return -EINVAL;
s = sizeof(struct disttable) + n * sizeof(s16); s = sizeof(struct disttable) + n * sizeof(s16);
d = kmalloc(s, GFP_KERNEL); d = kmalloc(s, GFP_KERNEL | __GFP_NOWARN);
if (!d) if (!d)
d = vmalloc(s); d = vmalloc(s);
if (!d) if (!d)
...@@ -501,9 +501,10 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) ...@@ -501,9 +501,10 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
root_lock = qdisc_root_sleeping_lock(sch); root_lock = qdisc_root_sleeping_lock(sch);
spin_lock_bh(root_lock); spin_lock_bh(root_lock);
dist_free(q->delay_dist); swap(q->delay_dist, d);
q->delay_dist = d;
spin_unlock_bh(root_lock); spin_unlock_bh(root_lock);
dist_free(d);
return 0; return 0;
} }
......
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