Bluetooth: check sock parent before unlink 19/87919/5
authorSudha Bheemanna <b.sudha@samsung.com>
Mon, 12 Sep 2016 06:27:38 +0000 (11:57 +0530)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 29 Sep 2016 05:40:22 +0000 (14:40 +0900)
Add a check for BT socket before using it to unlink
in bt_accept_unlink(). This helps to avoid kernel panic.

Change-Id: Ie8919dedce239a3476c06ad48ebb3a0f731b9856
Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
[update patch title]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
net/bluetooth/af_bluetooth.c

index 70f9d945faf7b439ce7a5283e94bc9687e8e67af..525ad0f1239d849a3610a96be3c975509663378a 100644 (file)
@@ -189,12 +189,18 @@ struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
                /* FIXME: Is this check still needed */
                if (sk->sk_state == BT_CLOSED) {
                        release_sock(sk);
+#ifdef TIZEN_BT
+                       if (bt_sk(sk)->parent)
+#endif
                        bt_accept_unlink(sk);
                        continue;
                }
 
                if (sk->sk_state == BT_CONNECTED || !newsock ||
                    test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags)) {
+#ifdef TIZEN_BT
+                       if (bt_sk(sk)->parent)
+#endif
                        bt_accept_unlink(sk);
                        if (newsock)
                                sock_graft(sk, newsock);