aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r--net/bluetooth/rfcomm/core.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 5759bb7054f7..4e32e18211f9 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -62,7 +62,6 @@ static DEFINE_MUTEX(rfcomm_mutex);
62#define rfcomm_lock() mutex_lock(&rfcomm_mutex) 62#define rfcomm_lock() mutex_lock(&rfcomm_mutex)
63#define rfcomm_unlock() mutex_unlock(&rfcomm_mutex) 63#define rfcomm_unlock() mutex_unlock(&rfcomm_mutex)
64 64
65static unsigned long rfcomm_event;
66 65
67static LIST_HEAD(session_list); 66static LIST_HEAD(session_list);
68 67
@@ -120,7 +119,6 @@ static inline void rfcomm_schedule(void)
120{ 119{
121 if (!rfcomm_thread) 120 if (!rfcomm_thread)
122 return; 121 return;
123 set_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
124 wake_up_process(rfcomm_thread); 122 wake_up_process(rfcomm_thread);
125} 123}
126 124
@@ -1804,6 +1802,11 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s)
1804 continue; 1802 continue;
1805 } 1803 }
1806 1804
1805 if (test_bit(RFCOMM_ENC_DROP, &d->flags)) {
1806 __rfcomm_dlc_close(d, ECONNREFUSED);
1807 continue;
1808 }
1809
1807 if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { 1810 if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) {
1808 rfcomm_dlc_clear_timer(d); 1811 rfcomm_dlc_clear_timer(d);
1809 if (d->out) { 1812 if (d->out) {
@@ -1855,7 +1858,10 @@ static inline void rfcomm_process_rx(struct rfcomm_session *s)
1855 /* Get data directly from socket receive queue without copying it. */ 1858 /* Get data directly from socket receive queue without copying it. */
1856 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { 1859 while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
1857 skb_orphan(skb); 1860 skb_orphan(skb);
1858 rfcomm_recv_frame(s, skb); 1861 if (!skb_linearize(skb))
1862 rfcomm_recv_frame(s, skb);
1863 else
1864 kfree_skb(skb);
1859 } 1865 }
1860 1866
1861 if (sk->sk_state == BT_CLOSED) { 1867 if (sk->sk_state == BT_CLOSED) {
@@ -2038,19 +2044,18 @@ static int rfcomm_run(void *unused)
2038 2044
2039 rfcomm_add_listener(BDADDR_ANY); 2045 rfcomm_add_listener(BDADDR_ANY);
2040 2046
2041 while (!kthread_should_stop()) { 2047 while (1) {
2042 set_current_state(TASK_INTERRUPTIBLE); 2048 set_current_state(TASK_INTERRUPTIBLE);
2043 if (!test_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event)) { 2049
2044 /* No pending events. Let's sleep. 2050 if (kthread_should_stop())
2045 * Incoming connections and data will wake us up. */ 2051 break;
2046 schedule();
2047 }
2048 set_current_state(TASK_RUNNING);
2049 2052
2050 /* Process stuff */ 2053 /* Process stuff */
2051 clear_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
2052 rfcomm_process_sessions(); 2054 rfcomm_process_sessions();
2055
2056 schedule();
2053 } 2057 }
2058 __set_current_state(TASK_RUNNING);
2054 2059
2055 rfcomm_kill_listener(); 2060 rfcomm_kill_listener();
2056 2061
@@ -2077,7 +2082,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt)
2077 if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) { 2082 if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) {
2078 rfcomm_dlc_clear_timer(d); 2083 rfcomm_dlc_clear_timer(d);
2079 if (status || encrypt == 0x00) { 2084 if (status || encrypt == 0x00) {
2080 __rfcomm_dlc_close(d, ECONNREFUSED); 2085 set_bit(RFCOMM_ENC_DROP, &d->flags);
2081 continue; 2086 continue;
2082 } 2087 }
2083 } 2088 }
@@ -2088,7 +2093,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt)
2088 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); 2093 rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT);
2089 continue; 2094 continue;
2090 } else if (d->sec_level == BT_SECURITY_HIGH) { 2095 } else if (d->sec_level == BT_SECURITY_HIGH) {
2091 __rfcomm_dlc_close(d, ECONNREFUSED); 2096 set_bit(RFCOMM_ENC_DROP, &d->flags);
2092 continue; 2097 continue;
2093 } 2098 }
2094 } 2099 }