Skip to content

Commit e891f5f

Browse files
Jie JiangChromium LUCI CQ
authored andcommitted
arc: bluetooth: Change DCHECK to an early return
The DCHECKs used ArcBluetoothBridge::ReadGattCharacteristic() can be triggered in some cases. Change them to real checks to avoid crashes. Bug: chromium:1243075 Test: Build Change-Id: I76ad299712934a03b43360f9da645456e6837582 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3193239 Reviewed-by: Hidehiko Abe <[email protected]> Commit-Queue: Jie Jiang <[email protected]> Cr-Commit-Position: refs/heads/main@{#927559}
1 parent b84d450 commit e891f5f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

chrome/browser/ash/arc/bluetooth/arc_bluetooth_bridge.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,8 +1705,21 @@ void ArcBluetoothBridge::ReadGattCharacteristic(
17051705
ReadGattCharacteristicCallback callback) {
17061706
BluetoothRemoteGattCharacteristic* characteristic = FindGattCharacteristic(
17071707
std::move(remote_addr), std::move(service_id), std::move(char_id));
1708-
DCHECK(characteristic);
1709-
DCHECK(characteristic->GetPermissions() & kGattReadPermission);
1708+
if (!characteristic) {
1709+
// TODO(b/201737474): Investigate in what case this could happen.
1710+
LOG(ERROR) << "Requested GATT characteristic does not exist";
1711+
OnGattRead(std::move(callback),
1712+
device::BluetoothGattService::GATT_ERROR_FAILED, /*result=*/{});
1713+
return;
1714+
}
1715+
if (!(characteristic->GetPermissions() & kGattReadPermission)) {
1716+
// TODO(b/201737474): Investigate in what case this could happen.
1717+
LOG(ERROR) << "Requested GATT characteristic does not have read permission";
1718+
OnGattRead(std::move(callback),
1719+
device::BluetoothGattService::GATT_ERROR_NOT_PERMITTED,
1720+
/*result=*/{});
1721+
return;
1722+
}
17101723

17111724
characteristic->ReadRemoteCharacteristic(
17121725
base::BindOnce(&OnGattRead, std::move(callback)));

0 commit comments

Comments
 (0)