OSDN Git Service

Don't fail if the CE key isn't loaded in destroy_user_key
authorPaul Crowley <paulcrowley@google.com>
Fri, 25 Mar 2016 22:50:01 +0000 (15:50 -0700)
committerPaul Crowley <paulcrowley@google.com>
Tue, 29 Mar 2016 20:07:34 +0000 (13:07 -0700)
Users don't have to be unlocked to be deleted, so don't worry if we
don't have their key to evict.

Bug: 26847403
Bug: 27441228
Change-Id: Ifd93f620926630aa102a3bb4a5d2d45d34f9b75d

Ext4Crypt.cpp

index 3a31861..11f104a 100644 (file)
@@ -443,7 +443,10 @@ bool e4crypt_destroy_user_key(userid_t user_id) {
     bool success = true;
     s_ce_keys.erase(user_id);
     std::string raw_ref;
-    success &= lookup_key_ref(s_ce_key_raw_refs, user_id, &raw_ref) && evict_key(raw_ref);
+    // If we haven't loaded the CE key, no need to evict it.
+    if (lookup_key_ref(s_ce_key_raw_refs, user_id, &raw_ref)) {
+        success &= evict_key(raw_ref);
+    }
     s_ce_key_raw_refs.erase(user_id);
     success &= lookup_key_ref(s_de_key_raw_refs, user_id, &raw_ref) && evict_key(raw_ref);
     s_de_key_raw_refs.erase(user_id);