OSDN Git Service

Avoid double memory free and crash during LE discovery or disconnect
authorNitin Arora <niarora@codeaurora.org>
Thu, 28 Jan 2016 01:02:02 +0000 (17:02 -0800)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 28 Jan 2016 22:23:52 +0000 (22:23 +0000)
commit12091a323ef84cad10d91fcf6588a6657e591ee0
tree84d820c1c5855b53e34d70ebf29fbb932048ebf7
parent8eea109d265c7c03d80ceb681f05b3604ec939ad
Avoid double memory free and crash during LE discovery or disconnect

1. Prevent GATT operations to proceed if queue is not empty

This change returns a FALSE from GATT enqueue operation, in case
there is already a GATT command enqueued. This simple change will
a. Prevent incorrect memory freeing of the currently queued command.
b. Prevent incorrect dequeing of the ongoing command and enqueing
another command which will never be executed.
c. Double free of memory causing segmentation fault

2. Prevent performing pending operations when link is down

This change prevents performing the execution of pending operations
when the link is disconnected. The pending operation in that case
is bound to fail thus freeing the memory pointed to by the p_q_cmd
which is cleaned up again by the discovery completion routine and
thus causing double free.

Bug:24178843
Change-Id: Ief2756f289a7db73d251ef7e247774dd3f7fc413
bta/gatt/bta_gattc_act.c
bta/gatt/bta_gattc_utils.c