android/bluetooth: Fix adding device to bonded list multiple times

Current bearer pair state needs to be checked as well since event
triggering state update can be received multiple times.

This fix crash on bluetoothd shutdown due to double free of device.
This commit is contained in:
Szymon Janc 2014-06-29 22:20:46 +02:00
parent f235a4bcc9
commit 75cb163190

View File

@ -793,7 +793,7 @@ static void update_bredr_state(struct device *dev, bool pairing, bool paired,
if (!pairing && !paired && dev->pairing && dev->bredr_paired)
goto done;
if (paired && !dev->le_paired) {
if (paired && !dev->le_paired && !dev->bredr_paired) {
cached_devices = g_slist_remove(cached_devices, dev);
bonded_devices = g_slist_prepend(bonded_devices, dev);
remove_device_info(dev, CACHE_FILE);
@ -826,7 +826,7 @@ static void update_le_state(struct device *dev, bool pairing, bool paired,
if (!pairing && !paired && dev->pairing && dev->le_paired)
goto done;
if (paired && !dev->bredr_paired) {
if (paired && !dev->bredr_paired && !dev->le_paired) {
cached_devices = g_slist_remove(cached_devices, dev);
bonded_devices = g_slist_prepend(bonded_devices, dev);
remove_device_info(dev, CACHE_FILE);