OSDN Git Service

RFCOMM: Add state check to prevent assert
authorSrinu Jella <sjella@codeaurora.org>
Mon, 7 Sep 2015 08:10:07 +0000 (13:40 +0530)
committerLinux Build Service Account <lnxbuild@localhost>
Wed, 24 Aug 2016 14:09:58 +0000 (08:09 -0600)
This patch adds state check in bta_jv_rfcomm_write, to prevent sending
data in BTA_JV_ST_NONE state. This would prevent ASSERT in code due to
null handle, as handle might have already been set to null during previous
closing of rfcomm connection.

CRs-Fixed: 1041625
Change-Id: Ibc6b1fb7aa6dce9a4acb52d724af3023fad9a9ae

bta/jv/bta_jv_act.c

index 965b4b8..a1e7ad4 100644 (file)
@@ -2048,6 +2048,13 @@ void bta_jv_rfcomm_write(tBTA_JV_MSG *p_data)
     tBTA_JV_PCB     *p_pcb = wc->p_pcb;
     tBTA_JV_RFCOMM_WRITE    evt_data;
 
+
+    if (p_pcb->state == BTA_JV_ST_NONE) {
+        APPL_TRACE_ERROR("bta_jv_rfcomm_write : Incorect state (%d) to write data, returning",
+            p_pcb->state);
+        return;
+    }
+
     evt_data.status = BTA_JV_FAILURE;
     evt_data.handle = p_cb->handle;
     evt_data.req_id = wc->req_id;