FastbootDevice::boot1_1 null pointer dereference

FastbootDevice::boot1_1 attempts to dereference a null pointer when the
boot_control_hal_ is not set. It needs a guard statement to prevent
that.

Test: Manually tested on device without BootControl.
Bug: 301682120
Change-Id: Id86bcb915c8e2857bda26f64738dd5b643048e98
This commit is contained in:
Arun Sharma 2023-10-03 14:55:48 -07:00
parent b533f531df
commit 1a3456f0bc

View file

@ -151,7 +151,8 @@ std::string FastbootDevice::GetCurrentSlot() {
}
BootControlClient* FastbootDevice::boot1_1() const {
if (boot_control_hal_->GetVersion() >= android::hal::BootControlVersion::BOOTCTL_V1_1) {
if (boot_control_hal_ &&
boot_control_hal_->GetVersion() >= android::hal::BootControlVersion::BOOTCTL_V1_1) {
return boot_control_hal_.get();
}
return nullptr;