aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-09-29 11:56:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-29 11:56:47 -0400
commiteb693d2994eb762b2201aead31066265ab0be20b (patch)
tree424e1e7f3d272d0fd5888435176b386594ce121f /net
parent6dec3cf5cdb600f39b9eac3349f6bf50eab87731 (diff)
parent01d40f28b125e0a9aa0ec24642be67fc4c5dfaff (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'net')
-rw-r--r--net/appletalk/ddp.c31
-rw-r--r--net/atm/addr.c6
-rw-r--r--net/atm/common.c4
-rw-r--r--net/atm/ioctl.c34
-rw-r--r--net/atm/signaling.c8
-rw-r--r--net/atm/svc.c1
-rw-r--r--net/core/datagram.c81
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/sock.c20
-rw-r--r--net/ethernet/eth.c31
-rw-r--r--net/ipv4/tcp_output.c11
-rw-r--r--net/rose/af_rose.c26
-rw-r--r--net/socket.c13
13 files changed, 150 insertions, 118 deletions
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 1d31b3a3f1e5..7982656b9c83 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -100,8 +100,7 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
100 continue; 100 continue;
101 101
102 if (to->sat_addr.s_net == ATADDR_ANYNET && 102 if (to->sat_addr.s_net == ATADDR_ANYNET &&
103 to->sat_addr.s_node == ATADDR_BCAST && 103 to->sat_addr.s_node == ATADDR_BCAST)
104 at->src_net == atif->address.s_net)
105 goto found; 104 goto found;
106 105
107 if (to->sat_addr.s_net == at->src_net && 106 if (to->sat_addr.s_net == at->src_net &&
@@ -1443,8 +1442,10 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1443 else 1442 else
1444 atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode); 1443 atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode);
1445 1444
1446 /* Not ours, so we route the packet via the correct AppleTalk iface */
1447 if (!atif) { 1445 if (!atif) {
1446 /* Not ours, so we route the packet via the correct
1447 * AppleTalk iface
1448 */
1448 atalk_route_packet(skb, dev, ddp, &ddphv, origlen); 1449 atalk_route_packet(skb, dev, ddp, &ddphv, origlen);
1449 goto out; 1450 goto out;
1450 } 1451 }
@@ -1592,9 +1593,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1592 1593
1593 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { 1594 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) {
1594 rt = atrtr_find(&usat->sat_addr); 1595 rt = atrtr_find(&usat->sat_addr);
1595 if (!rt)
1596 return -ENETUNREACH;
1597
1598 dev = rt->dev; 1596 dev = rt->dev;
1599 } else { 1597 } else {
1600 struct atalk_addr at_hint; 1598 struct atalk_addr at_hint;
@@ -1603,11 +1601,12 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1603 at_hint.s_net = at->src_net; 1601 at_hint.s_net = at->src_net;
1604 1602
1605 rt = atrtr_find(&at_hint); 1603 rt = atrtr_find(&at_hint);
1606 if (!rt)
1607 return -ENETUNREACH;
1608
1609 dev = rt->dev; 1604 dev = rt->dev;
1610 } 1605 }
1606 if (!rt)
1607 return -ENETUNREACH;
1608
1609 dev = rt->dev;
1611 1610
1612 SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n", 1611 SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n",
1613 sk, size, dev->name); 1612 sk, size, dev->name);
@@ -1677,6 +1676,20 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1677 SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk); 1676 SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk);
1678 /* loop back */ 1677 /* loop back */
1679 skb_orphan(skb); 1678 skb_orphan(skb);
1679 if (ddp->deh_dnode == ATADDR_BCAST) {
1680 struct atalk_addr at_lo;
1681
1682 at_lo.s_node = 0;
1683 at_lo.s_net = 0;
1684
1685 rt = atrtr_find(&at_lo);
1686 if (!rt) {
1687 kfree_skb(skb);
1688 return -ENETUNREACH;
1689 }
1690 dev = rt->dev;
1691 skb->dev = dev;
1692 }
1680 ddp_dl->request(ddp_dl, skb, dev->dev_addr); 1693 ddp_dl->request(ddp_dl, skb, dev->dev_addr);
1681 } else { 1694 } else {
1682 SOCK_DEBUG(sk, "SK %p: send out.\n", sk); 1695 SOCK_DEBUG(sk, "SK %p: send out.\n", sk);
diff --git a/net/atm/addr.c b/net/atm/addr.c
index 1c8867f7f54a..a30d0bf48063 100644
--- a/net/atm/addr.c
+++ b/net/atm/addr.c
@@ -50,8 +50,10 @@ void atm_reset_addr(struct atm_dev *dev)
50 struct atm_dev_addr *this, *p; 50 struct atm_dev_addr *this, *p;
51 51
52 spin_lock_irqsave(&dev->lock, flags); 52 spin_lock_irqsave(&dev->lock, flags);
53 list_for_each_entry_safe(this, p, &dev->local, entry) 53 list_for_each_entry_safe(this, p, &dev->local, entry) {
54 kfree(this); 54 list_del(&this->entry);
55 kfree(this);
56 }
55 spin_unlock_irqrestore(&dev->lock, flags); 57 spin_unlock_irqrestore(&dev->lock, flags);
56 notify_sigd(dev); 58 notify_sigd(dev);
57} 59}
diff --git a/net/atm/common.c b/net/atm/common.c
index e93e838069e8..801a5813ec60 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -178,8 +178,6 @@ static void vcc_destroy_socket(struct sock *sk)
178 if (vcc->push) 178 if (vcc->push)
179 vcc->push(vcc, NULL); /* atmarpd has no push */ 179 vcc->push(vcc, NULL); /* atmarpd has no push */
180 180
181 vcc_remove_socket(sk); /* no more receive */
182
183 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 181 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
184 atm_return(vcc,skb->truesize); 182 atm_return(vcc,skb->truesize);
185 kfree_skb(skb); 183 kfree_skb(skb);
@@ -188,6 +186,8 @@ static void vcc_destroy_socket(struct sock *sk)
188 module_put(vcc->dev->ops->owner); 186 module_put(vcc->dev->ops->owner);
189 atm_dev_put(vcc->dev); 187 atm_dev_put(vcc->dev);
190 } 188 }
189
190 vcc_remove_socket(sk);
191} 191}
192 192
193 193
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index d89056ec44d4..a150198b05a3 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -105,17 +105,35 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
105 if (!error) 105 if (!error)
106 sock->state = SS_CONNECTED; 106 sock->state = SS_CONNECTED;
107 goto done; 107 goto done;
108 default: 108 case ATM_SETBACKEND:
109 case ATM_NEWBACKENDIF:
110 {
111 atm_backend_t backend;
112 error = get_user(backend, (atm_backend_t __user *) argp);
113 if (error)
114 goto done;
115 switch (backend) {
116 case ATM_BACKEND_PPP:
117 request_module("pppoatm");
118 break;
119 case ATM_BACKEND_BR2684:
120 request_module("br2684");
121 break;
122 }
123 }
124 break;
125 case ATMMPC_CTRL:
126 case ATMMPC_DATA:
127 request_module("mpoa");
128 break;
129 case ATMARPD_CTRL:
130 request_module("clip");
131 break;
132 case ATMLEC_CTRL:
133 request_module("lec");
109 break; 134 break;
110 } 135 }
111 136
112 if (cmd == ATMMPC_CTRL || cmd == ATMMPC_DATA)
113 request_module("mpoa");
114 if (cmd == ATMARPD_CTRL)
115 request_module("clip");
116 if (cmd == ATMLEC_CTRL)
117 request_module("lec");
118
119 error = -ENOIOCTLCMD; 137 error = -ENOIOCTLCMD;
120 138
121 down(&ioctl_mutex); 139 down(&ioctl_mutex);
diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index f7c449ac1800..e7211a7f382c 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -217,8 +217,9 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type,
217static void purge_vcc(struct atm_vcc *vcc) 217static void purge_vcc(struct atm_vcc *vcc)
218{ 218{
219 if (sk_atm(vcc)->sk_family == PF_ATMSVC && 219 if (sk_atm(vcc)->sk_family == PF_ATMSVC &&
220 !test_bit(ATM_VF_META,&vcc->flags)) { 220 !test_bit(ATM_VF_META, &vcc->flags)) {
221 set_bit(ATM_VF_RELEASED,&vcc->flags); 221 set_bit(ATM_VF_RELEASED, &vcc->flags);
222 clear_bit(ATM_VF_REGIS, &vcc->flags);
222 vcc_release_async(vcc, -EUNATCH); 223 vcc_release_async(vcc, -EUNATCH);
223 } 224 }
224} 225}
@@ -243,8 +244,7 @@ static void sigd_close(struct atm_vcc *vcc)
243 sk_for_each(s, node, head) { 244 sk_for_each(s, node, head) {
244 struct atm_vcc *vcc = atm_sk(s); 245 struct atm_vcc *vcc = atm_sk(s);
245 246
246 if (vcc->dev) 247 purge_vcc(vcc);
247 purge_vcc(vcc);
248 } 248 }
249 } 249 }
250 read_unlock(&vcc_sklist_lock); 250 read_unlock(&vcc_sklist_lock);
diff --git a/net/atm/svc.c b/net/atm/svc.c
index 08e46052a3e4..d7b266136bf6 100644
--- a/net/atm/svc.c
+++ b/net/atm/svc.c
@@ -302,6 +302,7 @@ static int svc_listen(struct socket *sock,int backlog)
302 error = -EINVAL; 302 error = -EINVAL;
303 goto out; 303 goto out;
304 } 304 }
305 vcc_insert_socket(sk);
305 set_bit(ATM_VF_WAITING, &vcc->flags); 306 set_bit(ATM_VF_WAITING, &vcc->flags);
306 prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); 307 prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE);
307 sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); 308 sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local);
diff --git a/net/core/datagram.c b/net/core/datagram.c
index da9bf71421a7..81987df536eb 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -211,74 +211,45 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
211int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, 211int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
212 struct iovec *to, int len) 212 struct iovec *to, int len)
213{ 213{
214 int start = skb_headlen(skb); 214 int i, err, fraglen, end = 0;
215 int i, copy = start - offset; 215 struct sk_buff *next = skb_shinfo(skb)->frag_list;
216 216next_skb:
217 /* Copy header. */ 217 fraglen = skb_headlen(skb);
218 if (copy > 0) { 218 i = -1;
219 if (copy > len)
220 copy = len;
221 if (memcpy_toiovec(to, skb->data + offset, copy))
222 goto fault;
223 if ((len -= copy) == 0)
224 return 0;
225 offset += copy;
226 }
227 219
228 /* Copy paged appendix. Hmm... why does this look so complicated? */ 220 while (1) {
229 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 221 int start = end;
230 int end;
231
232 BUG_TRAP(start <= offset + len);
233 222
234 end = start + skb_shinfo(skb)->frags[i].size; 223 if ((end += fraglen) > offset) {
235 if ((copy = end - offset) > 0) { 224 int copy = end - offset, o = offset - start;
236 int err;
237 u8 *vaddr;
238 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
239 struct page *page = frag->page;
240 225
241 if (copy > len) 226 if (copy > len)
242 copy = len; 227 copy = len;
243 vaddr = kmap(page); 228 if (i == -1)
244 err = memcpy_toiovec(to, vaddr + frag->page_offset + 229 err = memcpy_toiovec(to, skb->data + o, copy);
245 offset - start, copy); 230 else {
246 kunmap(page); 231 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
232 struct page *page = frag->page;
233 void *p = kmap(page) + frag->page_offset + o;
234 err = memcpy_toiovec(to, p, copy);
235 kunmap(page);
236 }
247 if (err) 237 if (err)
248 goto fault; 238 goto fault;
249 if (!(len -= copy)) 239 if (!(len -= copy))
250 return 0; 240 return 0;
251 offset += copy; 241 offset += copy;
252 } 242 }
253 start = end; 243 if (++i >= skb_shinfo(skb)->nr_frags)
244 break;
245 fraglen = skb_shinfo(skb)->frags[i].size;
254 } 246 }
255 247 if (next) {
256 if (skb_shinfo(skb)->frag_list) { 248 skb = next;
257 struct sk_buff *list = skb_shinfo(skb)->frag_list; 249 BUG_ON(skb_shinfo(skb)->frag_list);
258 250 next = skb->next;
259 for (; list; list = list->next) { 251 goto next_skb;
260 int end;
261
262 BUG_TRAP(start <= offset + len);
263
264 end = start + list->len;
265 if ((copy = end - offset) > 0) {
266 if (copy > len)
267 copy = len;
268 if (skb_copy_datagram_iovec(list,
269 offset - start,
270 to, copy))
271 goto fault;
272 if ((len -= copy) == 0)
273 return 0;
274 offset += copy;
275 }
276 start = end;
277 }
278 } 252 }
279 if (!len)
280 return 0;
281
282fault: 253fault:
283 return -EFAULT; 254 return -EFAULT;
284} 255}
diff --git a/net/core/dev.c b/net/core/dev.c
index 37c881070963..9066c874e273 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1259,6 +1259,8 @@ int dev_queue_xmit(struct sk_buff *skb)
1259 if (skb_checksum_help(skb, 0)) 1259 if (skb_checksum_help(skb, 0))
1260 goto out_kfree_skb; 1260 goto out_kfree_skb;
1261 1261
1262 spin_lock_prefetch(&dev->queue_lock);
1263
1262 /* Disable soft irqs for various locks below. Also 1264 /* Disable soft irqs for various locks below. Also
1263 * stops preemption for RCU. 1265 * stops preemption for RCU.
1264 */ 1266 */
diff --git a/net/core/sock.c b/net/core/sock.c
index ac63b56e23b2..928d2a1d6d8e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority,
660 sock_lock_init(sk); 660 sock_lock_init(sk);
661 } 661 }
662 662
663 if (security_sk_alloc(sk, family, priority)) { 663 if (security_sk_alloc(sk, family, priority))
664 if (slab != NULL) 664 goto out_free;
665 kmem_cache_free(slab, sk); 665
666 else 666 if (!try_module_get(prot->owner))
667 kfree(sk); 667 goto out_free;
668 sk = NULL;
669 } else
670 __module_get(prot->owner);
671 } 668 }
672 return sk; 669 return sk;
670
671out_free:
672 if (slab != NULL)
673 kmem_cache_free(slab, sk);
674 else
675 kfree(sk);
676 return NULL;
673} 677}
674 678
675void sk_free(struct sock *sk) 679void sk_free(struct sock *sk)
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 87a052a9a84f..68a5ca866442 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -146,6 +146,19 @@ int eth_rebuild_header(struct sk_buff *skb)
146 return 0; 146 return 0;
147} 147}
148 148
149static inline unsigned int compare_eth_addr(const unsigned char *__a, const unsigned char *__b)
150{
151 const unsigned short *dest = (unsigned short *) __a;
152 const unsigned short *devaddr = (unsigned short *) __b;
153 unsigned int res;
154
155 BUILD_BUG_ON(ETH_ALEN != 6);
156 res = ((dest[0] ^ devaddr[0]) |
157 (dest[1] ^ devaddr[1]) |
158 (dest[2] ^ devaddr[2])) != 0;
159
160 return res;
161}
149 162
150/* 163/*
151 * Determine the packet's protocol ID. The rule here is that we 164 * Determine the packet's protocol ID. The rule here is that we
@@ -158,16 +171,15 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
158 struct ethhdr *eth; 171 struct ethhdr *eth;
159 unsigned char *rawp; 172 unsigned char *rawp;
160 173
161 skb->mac.raw=skb->data; 174 skb->mac.raw = skb->data;
162 skb_pull(skb,ETH_HLEN); 175 skb_pull(skb,ETH_HLEN);
163 eth = eth_hdr(skb); 176 eth = eth_hdr(skb);
164 177
165 if(*eth->h_dest&1) 178 if (*eth->h_dest&1) {
166 { 179 if (!compare_eth_addr(eth->h_dest, dev->broadcast))
167 if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) 180 skb->pkt_type = PACKET_BROADCAST;
168 skb->pkt_type=PACKET_BROADCAST;
169 else 181 else
170 skb->pkt_type=PACKET_MULTICAST; 182 skb->pkt_type = PACKET_MULTICAST;
171 } 183 }
172 184
173 /* 185 /*
@@ -178,10 +190,9 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
178 * seems to set IFF_PROMISC. 190 * seems to set IFF_PROMISC.
179 */ 191 */
180 192
181 else if(1 /*dev->flags&IFF_PROMISC*/) 193 else if(1 /*dev->flags&IFF_PROMISC*/) {
182 { 194 if (unlikely(compare_eth_addr(eth->h_dest, dev->dev_addr)))
183 if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN)) 195 skb->pkt_type = PACKET_OTHERHOST;
184 skb->pkt_type=PACKET_OTHERHOST;
185 } 196 }
186 197
187 if (ntohs(eth->h_proto) >= 1536) 198 if (ntohs(eth->h_proto) >= 1536)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index d6e3d269e906..caf2e2cff293 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -190,15 +190,16 @@ void tcp_select_initial_window(int __space, __u32 mss,
190 } 190 }
191 191
192 /* Set initial window to value enough for senders, 192 /* Set initial window to value enough for senders,
193 * following RFC1414. Senders, not following this RFC, 193 * following RFC2414. Senders, not following this RFC,
194 * will be satisfied with 2. 194 * will be satisfied with 2.
195 */ 195 */
196 if (mss > (1<<*rcv_wscale)) { 196 if (mss > (1<<*rcv_wscale)) {
197 int init_cwnd = 4; 197 int init_cwnd;
198 if (mss > 1460*3) 198
199 if (mss > 1460)
199 init_cwnd = 2; 200 init_cwnd = 2;
200 else if (mss > 1460) 201 else
201 init_cwnd = 3; 202 init_cwnd = (mss > 1095) ? 3 : 4;
202 if (*rcv_wnd > init_cwnd*mss) 203 if (*rcv_wnd > init_cwnd*mss)
203 *rcv_wnd = init_cwnd*mss; 204 *rcv_wnd = init_cwnd*mss;
204 } 205 }
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 5acb1680524a..829fdbc4400b 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1472,22 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62
1472static int __init rose_proto_init(void) 1472static int __init rose_proto_init(void)
1473{ 1473{
1474 int i; 1474 int i;
1475 int rc = proto_register(&rose_proto, 0); 1475 int rc;
1476 1476
1477 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1478 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1479 rc = -EINVAL;
1480 goto out;
1481 }
1482
1483 rc = proto_register(&rose_proto, 0);
1477 if (rc != 0) 1484 if (rc != 0)
1478 goto out; 1485 goto out;
1479 1486
1480 rose_callsign = null_ax25_address; 1487 rose_callsign = null_ax25_address;
1481 1488
1482 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1483 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1484 return -1;
1485 }
1486
1487 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); 1489 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
1488 if (dev_rose == NULL) { 1490 if (dev_rose == NULL) {
1489 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); 1491 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
1490 return -1; 1492 rc = -ENOMEM;
1493 goto out_proto_unregister;
1491 } 1494 }
1492 1495
1493 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); 1496 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*));
@@ -1500,10 +1503,12 @@ static int __init rose_proto_init(void)
1500 name, rose_setup); 1503 name, rose_setup);
1501 if (!dev) { 1504 if (!dev) {
1502 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n"); 1505 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
1506 rc = -ENOMEM;
1503 goto fail; 1507 goto fail;
1504 } 1508 }
1505 if (register_netdev(dev)) { 1509 rc = register_netdev(dev);
1506 printk(KERN_ERR "ROSE: netdevice regeistration failed\n"); 1510 if (rc) {
1511 printk(KERN_ERR "ROSE: netdevice registration failed\n");
1507 free_netdev(dev); 1512 free_netdev(dev);
1508 goto fail; 1513 goto fail;
1509 } 1514 }
@@ -1536,8 +1541,9 @@ fail:
1536 free_netdev(dev_rose[i]); 1541 free_netdev(dev_rose[i]);
1537 } 1542 }
1538 kfree(dev_rose); 1543 kfree(dev_rose);
1544out_proto_unregister:
1539 proto_unregister(&rose_proto); 1545 proto_unregister(&rose_proto);
1540 return -ENOMEM; 1546 goto out;
1541} 1547}
1542module_init(rose_proto_init); 1548module_init(rose_proto_init);
1543 1549
diff --git a/net/socket.c b/net/socket.c
index dbd1a6851edd..3145103cdf54 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
1145 if (!try_module_get(net_families[family]->owner)) 1145 if (!try_module_get(net_families[family]->owner))
1146 goto out_release; 1146 goto out_release;
1147 1147
1148 if ((err = net_families[family]->create(sock, protocol)) < 0) 1148 if ((err = net_families[family]->create(sock, protocol)) < 0) {
1149 sock->ops = NULL;
1149 goto out_module_put; 1150 goto out_module_put;
1151 }
1152
1150 /* 1153 /*
1151 * Now to bump the refcnt of the [loadable] module that owns this 1154 * Now to bump the refcnt of the [loadable] module that owns this
1152 * socket at sock_release time we decrement its refcnt. 1155 * socket at sock_release time we decrement its refcnt.
@@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
1360 newsock->type = sock->type; 1363 newsock->type = sock->type;
1361 newsock->ops = sock->ops; 1364 newsock->ops = sock->ops;
1362 1365
1363 err = security_socket_accept(sock, newsock);
1364 if (err)
1365 goto out_release;
1366
1367 /* 1366 /*
1368 * We don't need try_module_get here, as the listening socket (sock) 1367 * We don't need try_module_get here, as the listening socket (sock)
1369 * has the protocol module (sock->ops->owner) held. 1368 * has the protocol module (sock->ops->owner) held.
1370 */ 1369 */
1371 __module_get(newsock->ops->owner); 1370 __module_get(newsock->ops->owner);
1372 1371
1372 err = security_socket_accept(sock, newsock);
1373 if (err)
1374 goto out_release;
1375
1373 err = sock->ops->accept(sock, newsock, sock->file->f_flags); 1376 err = sock->ops->accept(sock, newsock, sock->file->f_flags);
1374 if (err < 0) 1377 if (err < 0)
1375 goto out_release; 1378 goto out_release;