diff options
author | Janis Danisevskis <jdanis@google.com> | 2022-02-15 13:27:44 -0800 |
---|---|---|
committer | Janis Danisevskis <jdanis@google.com> | 2022-03-02 12:25:56 -0800 |
commit | 99e4a381a194384a809dfa9df940febce56c80df (patch) | |
tree | 501eaf0742adecf02975146e39a029aae83cc207 | |
parent | 0661671a0498bddce4987f0dbef72926cc8245c0 (diff) | |
download | keymaster-99e4a381a194384a809dfa9df940febce56c80df.tar.gz |
KeyMint: CreateKeyMintDevice retruns shared_ptr.
Fix reference counting by creating AndroidKeyMintDevice using
ndk::SharedRefBase::make instead of new.
Bug: 219791936
Test: atest keystore2_km_compat_test_cpp does not crash any more.
Change-Id: I4dfc9e8703ae5f51de5e8944d74157e9818bfe40
-rw-r--r-- | ng/AndroidKeyMintDevice.cpp | 4 | ||||
-rw-r--r-- | ng/include/AndroidKeyMintDevice.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/ng/AndroidKeyMintDevice.cpp b/ng/AndroidKeyMintDevice.cpp index 373ec03..9d2cc69 100644 --- a/ng/AndroidKeyMintDevice.cpp +++ b/ng/AndroidKeyMintDevice.cpp @@ -492,8 +492,8 @@ ScopedAStatus AndroidKeyMintDevice::sendRootOfTrust(const vector<uint8_t>& /* ro return kmError2ScopedAStatus(KM_ERROR_UNIMPLEMENTED); } -IKeyMintDevice* CreateKeyMintDevice(SecurityLevel securityLevel) { - return ::new AndroidKeyMintDevice(securityLevel); +std::shared_ptr<IKeyMintDevice> CreateKeyMintDevice(SecurityLevel securityLevel) { + return ndk::SharedRefBase::make<AndroidKeyMintDevice>(securityLevel); } } // namespace aidl::android::hardware::security::keymint diff --git a/ng/include/AndroidKeyMintDevice.h b/ng/include/AndroidKeyMintDevice.h index b1b27cb..06557be 100644 --- a/ng/include/AndroidKeyMintDevice.h +++ b/ng/include/AndroidKeyMintDevice.h @@ -94,6 +94,6 @@ class AndroidKeyMintDevice : public BnKeyMintDevice { SecurityLevel securityLevel_; }; -IKeyMintDevice* CreateKeyMintDevice(SecurityLevel securityLevel); +std::shared_ptr<IKeyMintDevice> CreateKeyMintDevice(SecurityLevel securityLevel); } // namespace aidl::android::hardware::security::keymint |