aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2010-11-01 14:43:53 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2010-12-01 18:04:42 -0500
commite0f0cb56364958223f0cb1f1b0b0eecf1b8dcb95 (patch)
tree9eb8016a9ea039e65b3120d8b5f3568031238d76 /net
parentcc11b9c14da4ca1c545b424dae2ae8fb1ab04063 (diff)
Bluetooth: Get rid of __l2cap_get_sock_by_psm()
l2cap_get_sock_by_psm() was the only user of this function, so I merged both into l2cap_get_sock_by_psm(). The socket lock now should be hold outside of l2cap_get_sock_by_psm() once we hold and release it inside the same function now. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 18a802cc0469..12b4aa2f8fc9 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -751,11 +751,13 @@ found:
751/* Find socket with psm and source bdaddr. 751/* Find socket with psm and source bdaddr.
752 * Returns closest match. 752 * Returns closest match.
753 */ 753 */
754static struct sock *__l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src) 754static struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
755{ 755{
756 struct sock *sk = NULL, *sk1 = NULL; 756 struct sock *sk = NULL, *sk1 = NULL;
757 struct hlist_node *node; 757 struct hlist_node *node;
758 758
759 read_lock(&l2cap_sk_list.lock);
760
759 sk_for_each(sk, node, &l2cap_sk_list.head) { 761 sk_for_each(sk, node, &l2cap_sk_list.head) {
760 if (state && sk->sk_state != state) 762 if (state && sk->sk_state != state)
761 continue; 763 continue;
@@ -770,20 +772,10 @@ static struct sock *__l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src
770 sk1 = sk; 772 sk1 = sk;
771 } 773 }
772 } 774 }
773 return node ? sk : sk1;
774}
775 775
776/* Find socket with given address (psm, src).
777 * Returns locked socket */
778static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
779{
780 struct sock *s;
781 read_lock(&l2cap_sk_list.lock);
782 s = __l2cap_get_sock_by_psm(state, psm, src);
783 if (s)
784 bh_lock_sock(s);
785 read_unlock(&l2cap_sk_list.lock); 776 read_unlock(&l2cap_sk_list.lock);
786 return s; 777
778 return node ? sk : sk1;
787} 779}
788 780
789static void l2cap_sock_destruct(struct sock *sk) 781static void l2cap_sock_destruct(struct sock *sk)
@@ -2934,6 +2926,8 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
2934 goto sendresp; 2926 goto sendresp;
2935 } 2927 }
2936 2928
2929 bh_lock_sock(parent);
2930
2937 /* Check if the ACL is secure enough (if not SDP) */ 2931 /* Check if the ACL is secure enough (if not SDP) */
2938 if (psm != cpu_to_le16(0x0001) && 2932 if (psm != cpu_to_le16(0x0001) &&
2939 !hci_conn_check_link_mode(conn->hcon)) { 2933 !hci_conn_check_link_mode(conn->hcon)) {
@@ -4464,6 +4458,8 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
4464 if (!sk) 4458 if (!sk)
4465 goto drop; 4459 goto drop;
4466 4460
4461 bh_lock_sock(sk);
4462
4467 BT_DBG("sk %p, len %d", sk, skb->len); 4463 BT_DBG("sk %p, len %d", sk, skb->len);
4468 4464
4469 if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) 4465 if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED)