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

Commit ba0ee579 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

Avoid potential null dereference

We move our null check of 'p_dev' to before the first time we
dereference it.

Tag: #stability
Bug: 179741365
Test: TreeHuggger
Change-Id: Iafc45c9f82b88f9f0462f87b029789e861509287
parent 420cbb5e
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2838,18 +2838,18 @@ bool iterate_supported_event_list_for_timeout(void* data, void* cb_data) {
 **************************************************************************/
static void rc_notification_interim_timout(uint8_t label,
                                           btif_rc_device_cb_t* p_dev) {
  list_node_t* node;
  rc_context_t cntxt;
  memset(&cntxt, 0, sizeof(rc_context_t));
  cntxt.label = label;
  cntxt.rc_addr = p_dev->rc_addr;

  /* Device disconnections clear the event list but can't free the timer */
  if (p_dev == NULL || p_dev->rc_supported_event_list) {
    BTIF_TRACE_WARNING("%s: timeout for null device or event list", __func__);
    return;
  }

  list_node_t* node;
  rc_context_t cntxt;
  memset(&cntxt, 0, sizeof(rc_context_t));
  cntxt.label = label;
  cntxt.rc_addr = p_dev->rc_addr;

  list_foreach(p_dev->rc_supported_event_list,
               iterate_supported_event_list_for_timeout, &cntxt);
  /* Timeout happened for interim response for the registered event,