Commit: 9541d862f012ff0d00b5cc86613b80f0d2d89afc
Parent: 14151f9b528c654fd4b092b06ddb55d37f80aeb1
Author: Archie Pusaka <apusaka@chromium.org>
Committer: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: 2020-03-13 01:24:44
Tree: 40efd67ed3ecece0657865bfdf70452c680fd9cf

a2dp: Fix race when connecting and being connected at the same time There is a possibility where BlueZ initiate an A2DP connection just around the same time as the peripheral also initiate it. One scenario is the peripheral initiate the connection first, so confirm_cb() on /profiles/audio/a2dp.c is called. However, while we are waiting for the authentication step, BlueZ initiate a connection to the peripheral, therefore a2dp_sink_connect() is called, which from there a2dp_avdtp_get() is called. If this happens: When calling confirm_cb(), chan for the corresponding device is created. Then when calling a2dp_avdtp_get(), chan will be found as it is created in confirm_cb(), and the value of chan->io is not NULL. However, a NULL is supplied instead to create a new session and assigned to chan->session. Then when calling connect_cb(), chan->session will NOT be NULL, as it is assigned in a2dp_avdtp_get(). Nevertheless, chan->session is always assigned a new value. These cause failure in connection. Therefore, fixing this by supplying the value of chan->io inside a2dp_avdtp_get() (it's going to be NULL on the normal case so it is fine), and check whether chan->session already assigned inside connect_cb().

Diffstat

M profiles/audio/a2dp.c | 11 +++++++- - - -

1 files changed, 7 insertions(+), 4 deletions(-)

View Full Diff | Patch