bluez5: guard against transports without sco_io

If backend releases transport early and sco_io becomes NULL, don't
access it.

Also guard against calloc failing in sco_io creation.
This commit is contained in:
Pauli Virtanen 2021-03-20 12:18:13 +02:00 committed by Wim Taymans
parent 79e098bdf2
commit 0385d0a07e
4 changed files with 21 additions and 6 deletions

View file

@ -1575,14 +1575,17 @@ static int spa_bt_transport_stop_release_timer(struct spa_bt_transport *transpor
return 0;
}
void spa_bt_transport_ensure_sco_io(struct spa_bt_transport *t, struct spa_loop *data_loop)
int spa_bt_transport_ensure_sco_io(struct spa_bt_transport *t, struct spa_loop *data_loop)
{
if (t->sco_io == NULL) {
t->sco_io = spa_bt_sco_io_create(data_loop,
t->fd,
t->read_mtu,
t->write_mtu);
if (t->sco_io == NULL)
return -ENOMEM;
}
return 0;
}
int64_t spa_bt_transport_get_delay_nsec(struct spa_bt_transport *t)