From e7152c38df0f89bf4610be982542a6983b55032e Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Wed, 8 Mar 2017 11:02:30 -0800 Subject: [PATCH] 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 --- Keymaster.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Keymaster.cpp b/Keymaster.cpp index 8d1a01b..04d504b 100644 --- a/Keymaster.cpp +++ b/Keymaster.cpp @@ -196,7 +196,12 @@ bool Keymaster::isSecure() { 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,