Fix missing error handling in keymaster comatibility check
The compatibility check assumes that the keymaster session was created
successfully which is a faulty assumption.
This patch adds propper error handling to the check.
Bug: 35576166
Change-Id: I0c70a0e53f488f8bd3164898722f490cd0573ce3
diff --git a/Keymaster.cpp b/Keymaster.cpp
index 8d1a01b..04d504b 100644
--- a/Keymaster.cpp
+++ b/Keymaster.cpp
@@ -196,7 +196,12 @@
using namespace ::android::vold;
int keymaster_compatibility_cryptfs_scrypt() {
- return Keymaster().isSecure();
+ Keymaster dev;
+ if (!dev) {
+ LOG(ERROR) << "Failed to initiate keymaster session";
+ return -1;
+ }
+ return dev.isSecure();
}
int keymaster_create_key_for_cryptfs_scrypt(uint32_t rsa_key_size,