Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0a2b418 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix a memory leak when disabling AVDTP"

parents 4d184874 a70403d7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2073,9 +2073,7 @@ void bta_av_dereg_comp(tBTA_AV_DATA* p_data) {
#endif
    }

    /* make sure that the timer is not active */
    alarm_cancel(p_scb->avrc_ct_timer);
    osi_free_and_reset((void**)&p_cb->p_scb[p_scb->hdi]);
    bta_av_free_scb(p_scb);
  }

  APPL_TRACE_DEBUG("%s: audio 0x%x, disable:%d", __func__, p_cb->reg_audio,
+1 −0
Original line number Diff line number Diff line
@@ -640,6 +640,7 @@ extern bool bta_av_is_scb_init(tBTA_AV_SCB* p_scb);
extern void bta_av_set_scb_sst_incoming(tBTA_AV_SCB* p_scb);
extern tBTA_AV_LCB* bta_av_find_lcb(const RawAddress& addr, uint8_t op);
extern const char* bta_av_sst_code(uint8_t state);
extern void bta_av_free_scb(tBTA_AV_SCB* p_scb);

/* main functions */
extern void bta_av_api_deregister(tBTA_AV_DATA* p_data);
+11 −0
Original line number Diff line number Diff line
@@ -330,6 +330,17 @@ static tBTA_AV_SCB* bta_av_alloc_scb(tBTA_AV_CHNL chnl) {
  return nullptr;
}

void bta_av_free_scb(tBTA_AV_SCB* p_scb) {
  if (p_scb == nullptr) return;
  uint8_t scb_index = p_scb->hdi;
  CHECK(scb_index < BTA_AV_NUM_STRS);

  CHECK(p_scb == bta_av_cb.p_scb[scb_index]);
  bta_av_cb.p_scb[scb_index] = nullptr;
  alarm_free(p_scb->avrc_ct_timer);
  osi_free(p_scb);
}

/*******************************************************************************
 ******************************************************************************/
void bta_av_conn_cback(UNUSED_ATTR uint8_t handle, const RawAddress& bd_addr,