bluetooth: don't create the HSP/HFP profile twice
authorTanu Kaskinen <tanuk@iki.fi>
Sat, 30 Jul 2016 23:44:55 +0000 (02:44 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Wed, 10 Aug 2016 18:37:33 +0000 (21:37 +0300)
commit32c2a6d64aaa1d14b06c1af27a616e58d04e8e79
tree0399e38ee51d19de6347635af1c69f5327f18584
parent83ac6c5ae52d8463f479b84a0829597f3b470caf
bluetooth: don't create the HSP/HFP profile twice

create_card_profile() used to get called separately for HSP and HFP,
so if a headset supports both profiles, a profile named
"headset_head_unit" would get created twice. The second instance would
get immediately freed, so that wasn't a particularly serious problem.
However, I think it makes more sense to create the profile only once.
This patch makes things so that before a profile is created, we check
what name that profile would have, and if a profile with that name
already exists, we don't create the profile.

A couple of Yocto releases (jethro and krogoth) have non-upstream
patches that suffer from this double creation. The patches add
associations between profiles and ports, and those associations use
the profile name as the key. When the second profile gets freed, the
associations between the profile and its ports get removed, and since
the profile name is used as the key, this erroneously affects the
first profile too. Crashing ensues.

BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=10018
src/modules/bluetooth/module-bluez4-device.c
src/modules/bluetooth/module-bluez5-device.c