Code: static void *btif_hl_select_thread(void *arg){
    fd_set org_set, curr_set;
 int r, max_curr_s, max_org_s;
    UNUSED(arg);

    BTIF_TRACE_DEBUG("entered btif_hl_select_thread");
    FD_ZERO(&org_set);
    max_org_s = btif_hl_select_wakeup_init(&org_set);
    BTIF_TRACE_DEBUG("max_s=%d ", max_org_s);

 for (;;)
 {
        r = 0;

         BTIF_TRACE_DEBUG("set curr_set = org_set ");
         curr_set = org_set;
         max_curr_s = max_org_s;
        int ret = select((max_curr_s + 1), &curr_set, NULL, NULL, NULL);
         BTIF_TRACE_DEBUG("select unblocked ret=%d", ret);
         if (ret == -1)
         {
            BTIF_TRACE_DEBUG("select() ret -1, exit the thread");
            btif_hl_thread_cleanup();
            select_thread_id = -1;
 return 0;
 }
 else if (ret)
 {
            BTIF_TRACE_DEBUG("btif_hl_select_wake_signaled, signal ret=%d", ret);
 if (btif_hl_select_wake_signaled(&curr_set))
 {
                r = btif_hl_select_wake_reset();
                BTIF_TRACE_DEBUG("btif_hl_select_wake_signaled, signal:%d", r);
 if (r == btif_hl_signal_select_wakeup || r == btif_hl_signal_select_close_connected )
 {
                    btif_hl_select_wakeup_callback(&org_set, r);
 }
 else if( r == btif_hl_signal_select_exit)
 {
                    btif_hl_thread_cleanup();
                    BTIF_TRACE_DEBUG("Exit hl_select_thread for btif_hl_signal_select_exit");
 return 0;
 }
 }

            btif_hl_select_monitor_callback(&curr_set, &org_set);
            max_org_s = btif_hl_update_maxfd(max_org_s);
 }
 else
            BTIF_TRACE_DEBUG("no data, select ret: %d\n", ret);
 }
    BTIF_TRACE_DEBUG("leaving hl_select_thread");
 return 0;
}

Vulnerability Type: DoS 
CWE ID: CWE-284
Summary: Bluetooth in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-08-01 allows attackers to cause a denial of service (loss of Bluetooth 911 functionality) via a crafted application that sends a signal to a Bluetooth process, aka internal bug 28885210.
Commit Message: DO NOT MERGE Fix potential DoS caused by delivering signal to BT process

Bug: 28885210
Change-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360

 Conflicts:
	btif/co/bta_hh_co.c
	btif/src/btif_core.c
Merge conflict resolution of ag/1161415 (referencing ag/1164670)
- Directly into mnc-mr2-release
