diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-22 13:12:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-22 13:12:54 -0500 |
commit | 7ef5f41c16fdddfc14e882a57200334614d8ffd6 (patch) | |
tree | 5b6b4f59587e826993cead051fd42e08d2b590da | |
parent | 3d44cc3e01ee1b40317f79ed54324e25c4f848df (diff) | |
parent | 739840d529eb7505d3cbfe9d468bf1440c9a8e27 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6:
ppp: fix segfaults introduced by netdev_priv changes
net: Fix module refcount leak in kernel_accept()
-rw-r--r-- | drivers/net/ppp_generic.c | 28 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 2 | ||||
-rw-r--r-- | net/socket.c | 1 |
3 files changed, 14 insertions, 17 deletions
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 7e857e938adb..714a23035de1 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -116,6 +116,7 @@ struct ppp { | |||
116 | unsigned long last_xmit; /* jiffies when last pkt sent 9c */ | 116 | unsigned long last_xmit; /* jiffies when last pkt sent 9c */ |
117 | unsigned long last_recv; /* jiffies when last pkt rcvd a0 */ | 117 | unsigned long last_recv; /* jiffies when last pkt rcvd a0 */ |
118 | struct net_device *dev; /* network interface device a4 */ | 118 | struct net_device *dev; /* network interface device a4 */ |
119 | int closing; /* is device closing down? a8 */ | ||
119 | #ifdef CONFIG_PPP_MULTILINK | 120 | #ifdef CONFIG_PPP_MULTILINK |
120 | int nxchan; /* next channel to send something on */ | 121 | int nxchan; /* next channel to send something on */ |
121 | u32 nxseq; /* next sequence number to send */ | 122 | u32 nxseq; /* next sequence number to send */ |
@@ -995,7 +996,7 @@ ppp_xmit_process(struct ppp *ppp) | |||
995 | struct sk_buff *skb; | 996 | struct sk_buff *skb; |
996 | 997 | ||
997 | ppp_xmit_lock(ppp); | 998 | ppp_xmit_lock(ppp); |
998 | if (ppp->dev) { | 999 | if (!ppp->closing) { |
999 | ppp_push(ppp); | 1000 | ppp_push(ppp); |
1000 | while (!ppp->xmit_pending | 1001 | while (!ppp->xmit_pending |
1001 | && (skb = skb_dequeue(&ppp->file.xq))) | 1002 | && (skb = skb_dequeue(&ppp->file.xq))) |
@@ -1463,8 +1464,7 @@ static inline void | |||
1463 | ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) | 1464 | ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) |
1464 | { | 1465 | { |
1465 | ppp_recv_lock(ppp); | 1466 | ppp_recv_lock(ppp); |
1466 | /* ppp->dev == 0 means interface is closing down */ | 1467 | if (!ppp->closing) |
1467 | if (ppp->dev) | ||
1468 | ppp_receive_frame(ppp, skb, pch); | 1468 | ppp_receive_frame(ppp, skb, pch); |
1469 | else | 1469 | else |
1470 | kfree_skb(skb); | 1470 | kfree_skb(skb); |
@@ -2498,18 +2498,16 @@ init_ppp_file(struct ppp_file *pf, int kind) | |||
2498 | */ | 2498 | */ |
2499 | static void ppp_shutdown_interface(struct ppp *ppp) | 2499 | static void ppp_shutdown_interface(struct ppp *ppp) |
2500 | { | 2500 | { |
2501 | struct net_device *dev; | ||
2502 | |||
2503 | mutex_lock(&all_ppp_mutex); | 2501 | mutex_lock(&all_ppp_mutex); |
2504 | ppp_lock(ppp); | ||
2505 | dev = ppp->dev; | ||
2506 | ppp->dev = NULL; | ||
2507 | ppp_unlock(ppp); | ||
2508 | /* This will call dev_close() for us. */ | 2502 | /* This will call dev_close() for us. */ |
2509 | if (dev) { | 2503 | ppp_lock(ppp); |
2510 | unregister_netdev(dev); | 2504 | if (!ppp->closing) { |
2511 | free_netdev(dev); | 2505 | ppp->closing = 1; |
2512 | } | 2506 | ppp_unlock(ppp); |
2507 | unregister_netdev(ppp->dev); | ||
2508 | } else | ||
2509 | ppp_unlock(ppp); | ||
2510 | |||
2513 | cardmap_set(&all_ppp_units, ppp->file.index, NULL); | 2511 | cardmap_set(&all_ppp_units, ppp->file.index, NULL); |
2514 | ppp->file.dead = 1; | 2512 | ppp->file.dead = 1; |
2515 | ppp->owner = NULL; | 2513 | ppp->owner = NULL; |
@@ -2554,7 +2552,7 @@ static void ppp_destroy_interface(struct ppp *ppp) | |||
2554 | if (ppp->xmit_pending) | 2552 | if (ppp->xmit_pending) |
2555 | kfree_skb(ppp->xmit_pending); | 2553 | kfree_skb(ppp->xmit_pending); |
2556 | 2554 | ||
2557 | kfree(ppp); | 2555 | free_netdev(ppp->dev); |
2558 | } | 2556 | } |
2559 | 2557 | ||
2560 | /* | 2558 | /* |
@@ -2616,7 +2614,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2616 | if (pch->file.hdrlen > ppp->file.hdrlen) | 2614 | if (pch->file.hdrlen > ppp->file.hdrlen) |
2617 | ppp->file.hdrlen = pch->file.hdrlen; | 2615 | ppp->file.hdrlen = pch->file.hdrlen; |
2618 | hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ | 2616 | hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ |
2619 | if (ppp->dev && hdrlen > ppp->dev->hard_header_len) | 2617 | if (hdrlen > ppp->dev->hard_header_len) |
2620 | ppp->dev->hard_header_len = hdrlen; | 2618 | ppp->dev->hard_header_len = hdrlen; |
2621 | list_add_tail(&pch->clist, &ppp->channels); | 2619 | list_add_tail(&pch->clist, &ppp->channels); |
2622 | ++ppp->n_channels; | 2620 | ++ppp->n_channels; |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index ba537fae0a4c..ce68e046d963 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -1786,8 +1786,6 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s) | |||
1786 | if (err < 0) | 1786 | if (err < 0) |
1787 | return; | 1787 | return; |
1788 | 1788 | ||
1789 | __module_get(nsock->ops->owner); | ||
1790 | |||
1791 | /* Set our callbacks */ | 1789 | /* Set our callbacks */ |
1792 | nsock->sk->sk_data_ready = rfcomm_l2data_ready; | 1790 | nsock->sk->sk_data_ready = rfcomm_l2data_ready; |
1793 | nsock->sk->sk_state_change = rfcomm_l2state_change; | 1791 | nsock->sk->sk_state_change = rfcomm_l2state_change; |
diff --git a/net/socket.c b/net/socket.c index 92764d836891..76ba80aeac1a 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -2307,6 +2307,7 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | |||
2307 | } | 2307 | } |
2308 | 2308 | ||
2309 | (*newsock)->ops = sock->ops; | 2309 | (*newsock)->ops = sock->ops; |
2310 | __module_get((*newsock)->ops->owner); | ||
2310 | 2311 | ||
2311 | done: | 2312 | done: |
2312 | return err; | 2313 | return err; |