aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/llc/af_llc.c37
-rw-r--r--net/llc/llc_conn.c12
-rw-r--r--net/llc/llc_input.c2
3 files changed, 26 insertions, 25 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 81a53791ed9c..aed61e6376ed 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -155,7 +155,7 @@ static int llc_ui_create(struct socket *sock, int protocol)
155 struct sock *sk; 155 struct sock *sk;
156 int rc = -ESOCKTNOSUPPORT; 156 int rc = -ESOCKTNOSUPPORT;
157 157
158 if (sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM) { 158 if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {
159 rc = -ENOMEM; 159 rc = -ENOMEM;
160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto); 160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto);
161 if (sk) { 161 if (sk) {
@@ -177,7 +177,7 @@ static int llc_ui_release(struct socket *sock)
177 struct sock *sk = sock->sk; 177 struct sock *sk = sock->sk;
178 struct llc_sock *llc; 178 struct llc_sock *llc;
179 179
180 if (!sk) 180 if (unlikely(sk == NULL))
181 goto out; 181 goto out;
182 sock_hold(sk); 182 sock_hold(sk);
183 lock_sock(sk); 183 lock_sock(sk);
@@ -294,10 +294,10 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
294 int rc = -EINVAL; 294 int rc = -EINVAL;
295 295
296 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); 296 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap);
297 if (!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)) 297 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
298 goto out; 298 goto out;
299 rc = -EAFNOSUPPORT; 299 rc = -EAFNOSUPPORT;
300 if (addr->sllc_family != AF_LLC) 300 if (unlikely(addr->sllc_family != AF_LLC))
301 goto out; 301 goto out;
302 if (!addr->sllc_sap) { 302 if (!addr->sllc_sap) {
303 rc = -EUSERS; 303 rc = -EUSERS;
@@ -358,7 +358,7 @@ static int llc_ui_shutdown(struct socket *sock, int how)
358 int rc = -ENOTCONN; 358 int rc = -ENOTCONN;
359 359
360 lock_sock(sk); 360 lock_sock(sk);
361 if (sk->sk_state != TCP_ESTABLISHED) 361 if (unlikely(sk->sk_state != TCP_ESTABLISHED))
362 goto out; 362 goto out;
363 rc = -EINVAL; 363 rc = -EINVAL;
364 if (how != 2) 364 if (how != 2)
@@ -396,10 +396,15 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
396 int rc = -EINVAL; 396 int rc = -EINVAL;
397 397
398 lock_sock(sk); 398 lock_sock(sk);
399 if (addrlen != sizeof(*addr)) 399 if (unlikely(addrlen != sizeof(*addr)))
400 goto out; 400 goto out;
401 rc = -EAFNOSUPPORT; 401 rc = -EAFNOSUPPORT;
402 if (addr->sllc_family != AF_LLC) 402 if (unlikely(addr->sllc_family != AF_LLC))
403 goto out;
404 if (unlikely(sk->sk_type != SOCK_STREAM))
405 goto out;
406 rc = -EALREADY;
407 if (unlikely(sock->state == SS_CONNECTING))
403 goto out; 408 goto out;
404 /* bind connection to sap if user hasn't done it. */ 409 /* bind connection to sap if user hasn't done it. */
405 if (sock_flag(sk, SOCK_ZAPPED)) { 410 if (sock_flag(sk, SOCK_ZAPPED)) {
@@ -410,11 +415,6 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
410 llc->daddr.lsap = addr->sllc_sap; 415 llc->daddr.lsap = addr->sllc_sap;
411 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN); 416 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
412 } 417 }
413 if (sk->sk_type != SOCK_STREAM)
414 goto out;
415 rc = -EALREADY;
416 if (sock->state == SS_CONNECTING)
417 goto out;
418 sock->state = SS_CONNECTING; 418 sock->state = SS_CONNECTING;
419 sk->sk_state = TCP_SYN_SENT; 419 sk->sk_state = TCP_SYN_SENT;
420 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap); 420 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap);
@@ -448,10 +448,10 @@ static int llc_ui_listen(struct socket *sock, int backlog)
448 int rc = -EINVAL; 448 int rc = -EINVAL;
449 449
450 lock_sock(sk); 450 lock_sock(sk);
451 if (sock->state != SS_UNCONNECTED) 451 if (unlikely(sock->state != SS_UNCONNECTED))
452 goto out; 452 goto out;
453 rc = -EOPNOTSUPP; 453 rc = -EOPNOTSUPP;
454 if (sk->sk_type != SOCK_STREAM) 454 if (unlikely(sk->sk_type != SOCK_STREAM))
455 goto out; 455 goto out;
456 rc = -EAGAIN; 456 rc = -EAGAIN;
457 if (sock_flag(sk, SOCK_ZAPPED)) 457 if (sock_flag(sk, SOCK_ZAPPED))
@@ -614,10 +614,11 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
614 dprintk("%s: accepting on %02X\n", __FUNCTION__, 614 dprintk("%s: accepting on %02X\n", __FUNCTION__,
615 llc_sk(sk)->laddr.lsap); 615 llc_sk(sk)->laddr.lsap);
616 lock_sock(sk); 616 lock_sock(sk);
617 if (sk->sk_type != SOCK_STREAM) 617 if (unlikely(sk->sk_type != SOCK_STREAM))
618 goto out; 618 goto out;
619 rc = -EINVAL; 619 rc = -EINVAL;
620 if (sock->state != SS_UNCONNECTED || sk->sk_state != TCP_LISTEN) 620 if (unlikely(sock->state != SS_UNCONNECTED ||
621 sk->sk_state != TCP_LISTEN))
621 goto out; 622 goto out;
622 /* wait for a connection to arrive. */ 623 /* wait for a connection to arrive. */
623 rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo); 624 rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo);
@@ -880,7 +881,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
880 int rc = -EINVAL, opt; 881 int rc = -EINVAL, opt;
881 882
882 lock_sock(sk); 883 lock_sock(sk);
883 if (level != SOL_LLC || optlen != sizeof(int)) 884 if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
884 goto out; 885 goto out;
885 rc = get_user(opt, (int __user *)optval); 886 rc = get_user(opt, (int __user *)optval);
886 if (rc) 887 if (rc)
@@ -955,7 +956,7 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
955 int val = 0, len = 0, rc = -EINVAL; 956 int val = 0, len = 0, rc = -EINVAL;
956 957
957 lock_sock(sk); 958 lock_sock(sk);
958 if (level != SOL_LLC) 959 if (unlikely(level != SOL_LLC))
959 goto out; 960 goto out;
960 rc = get_user(len, optlen); 961 rc = get_user(len, optlen);
961 if (rc) 962 if (rc)
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index 1f659e56d8e2..ce7b893ed1ab 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -64,12 +64,12 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
64 skb_get(skb); 64 skb_get(skb);
65 ev->ind_prim = ev->cfm_prim = 0; 65 ev->ind_prim = ev->cfm_prim = 0;
66 rc = llc_conn_service(sk, skb); /* sending event to state machine */ 66 rc = llc_conn_service(sk, skb); /* sending event to state machine */
67 if (rc) { 67 if (unlikely(rc != 0)) {
68 printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__); 68 printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__);
69 goto out_kfree_skb; 69 goto out_kfree_skb;
70 } 70 }
71 71
72 if (!ev->ind_prim && !ev->cfm_prim) { 72 if (unlikely(!ev->ind_prim && !ev->cfm_prim)) {
73 /* indicate or confirm not required */ 73 /* indicate or confirm not required */
74 /* XXX this is not very pretty, perhaps we should store 74 /* XXX this is not very pretty, perhaps we should store
75 * XXX indicate/confirm-needed state in the llc_conn_state_ev 75 * XXX indicate/confirm-needed state in the llc_conn_state_ev
@@ -80,7 +80,7 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
80 goto out_skb_put; 80 goto out_skb_put;
81 } 81 }
82 82
83 if (ev->ind_prim && ev->cfm_prim) /* Paranoia */ 83 if (unlikely(ev->ind_prim && ev->cfm_prim)) /* Paranoia */
84 skb_get(skb); 84 skb_get(skb);
85 85
86 switch (ev->ind_prim) { 86 switch (ev->ind_prim) {
@@ -762,14 +762,14 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
762 int rc = 0; 762 int rc = 0;
763 struct llc_sock *llc = llc_sk(sk); 763 struct llc_sock *llc = llc_sk(sk);
764 764
765 if (llc_backlog_type(skb) == LLC_PACKET) { 765 if (likely(llc_backlog_type(skb) == LLC_PACKET)) {
766 if (llc->state > 1) /* not closed */ 766 if (likely(llc->state > 1)) /* not closed */
767 rc = llc_conn_rcv(sk, skb); 767 rc = llc_conn_rcv(sk, skb);
768 else 768 else
769 goto out_kfree_skb; 769 goto out_kfree_skb;
770 } else if (llc_backlog_type(skb) == LLC_EVENT) { 770 } else if (llc_backlog_type(skb) == LLC_EVENT) {
771 /* timer expiration event */ 771 /* timer expiration event */
772 if (llc->state > 1) /* not closed */ 772 if (likely(llc->state > 1)) /* not closed */
773 rc = llc_conn_state_process(sk, skb); 773 rc = llc_conn_state_process(sk, skb);
774 else 774 else
775 goto out_kfree_skb; 775 goto out_kfree_skb;
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index 13b46240b7a1..60c1acac7c97 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -101,7 +101,7 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
101 u8 llc_len = 2; 101 u8 llc_len = 2;
102 struct llc_pdu_sn *pdu; 102 struct llc_pdu_sn *pdu;
103 103
104 if (!pskb_may_pull(skb, sizeof(*pdu))) 104 if (unlikely(!pskb_may_pull(skb, sizeof(*pdu))))
105 return 0; 105 return 0;
106 106
107 pdu = (struct llc_pdu_sn *)skb->data; 107 pdu = (struct llc_pdu_sn *)skb->data;