Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f69d8bc9 authored by Janis Danisevskis's avatar Janis Danisevskis
Browse files

Keymaster memory management is inconsistent

Object derived from RefBase must be owned by sp rather then other smart
pointer implementations.

Bug: 79474587
Change-Id: I866f67e1cb091efb3026450d50a410b5985539b6
parent 340c842f
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -80,8 +80,7 @@ std::ostream& operator<<(std::ostream& os, const Keymaster& keymaster) {
}

template <typename Wrapper>
std::vector<std::unique_ptr<Keymaster>> enumerateDevices(
    const sp<IServiceManager>& serviceManager) {
Keymaster::KeymasterSet enumerateDevices(const sp<IServiceManager>& serviceManager) {
    Keymaster::KeymasterSet result;

    bool foundDefault = false;
@@ -92,7 +91,7 @@ std::vector<std::unique_ptr<Keymaster>> enumerateDevices(
            auto device = Wrapper::WrappedIKeymasterDevice::getService(name);
            CHECK(device) << "Failed to get service for " << descriptor << " with interface name "
                          << name;
            result.push_back(std::unique_ptr<Keymaster>(new Wrapper(device, name)));
            result.push_back(new Wrapper(device, name));
        }
    });

@@ -100,7 +99,7 @@ std::vector<std::unique_ptr<Keymaster>> enumerateDevices(
        // "default" wasn't provided by listManifestByInterface.  Maybe there's a passthrough
        // implementation.
        auto device = Wrapper::WrappedIKeymasterDevice::getService("default");
        if (device) result.push_back(std::unique_ptr<Keymaster>(new Wrapper(device, "default")));
        if (device) result.push_back(new Wrapper(device, "default"));
    }

    return result;
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ namespace support {
 */
class Keymaster : public IKeymasterDevice {
  public:
    using KeymasterSet = std::vector<std::unique_ptr<Keymaster>>;
    using KeymasterSet = std::vector<android::sp<Keymaster>>;

    Keymaster(const hidl_string& descriptor, const hidl_string& instanceName)
        : descriptor_(descriptor), instanceName_(instanceName) {}