• Zhihai Xu's avatar
    DO NOT MERGE fix a potential native crash during bluetooth sutdown · 5a79e080
    Zhihai Xu authored
    When bluetooth is initialized which call gki_buffer_init,
    the buffer pool is allocated by GKI_os_malloc which is
    to call libc malloc function.
    When bluetooth is cleanup which call GKI_shutdown,
    the buffer pool will be  freed by GKI_os_free
    which is to call libc free function.
    So if we access the buffer, after the whole buffer pool is freed,
    we will get this native crash.
    if we call cleanup during bluetooth disabling:
    the state is still BTIF_CORE_STATE_DISABLING,
    then GKI_shutdown will call before bte_main_disable
    ( bt_hc_if->cleanup();), which is  before userial thread exit.
    Then we may trigger this native crash.
    
    bug:11793775
    Change-Id: Ic8ced12848d25f918a28f4d5ba29b803d6ac5bd7
    5a79e080
btif_core.c 47.7 KB