diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index 5729dbdc5e7ce372746fe481393984eaaa122a4b..9b08398a1cf228e76d6ac137f5ae69fadbe7175d 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -1727,7 +1727,7 @@ public:
         }
 
         String8 name8(name);
-        String8 filename(mKeyStore->getKeyNameForUidWithDir(name8, callingUid));
+        String8 filename(mKeyStore->getKeyNameForUidWithDir(name8, targetUid));
 
         return mKeyStore->importKey(data, length, filename.string(), callingUid, flags);
     }