OSDN Git Service

fix a potential native crash during bluetooth sutdown
authorZhihai Xu <zhihaixu@google.com>
Tue, 26 Nov 2013 01:30:59 +0000 (17:30 -0800)
committerZhihai Xu <zhihaixu@google.com>
Mon, 16 Dec 2013 21:32:44 +0000 (13:32 -0800)
commit6c65c2f3a372885a976c14b3ccacd0b5a5fbb8bd
tree788730e0bb15cafb93fd359e67fd74f74d94d91c
parentcaf8deb58af8a5480d325ab443d5c49649222456
fix a potential native crash during bluetooth sutdown

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
btif/src/bluetooth.c
btif/src/btif_core.c