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

Commit 3d3f67f3 authored by Jeff Tinker's avatar Jeff Tinker
Browse files

Part of fix for TEE resource leaks when app crashes

bug: 9672606
Change-Id: I98cf65260d5e43d34e3897452f6f26ed2c89294e
parent a691ff3c
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -71,6 +71,12 @@ status_t Drm::initCheck() const {
status_t Drm::setListener(const sp<IDrmClient>& listener)
{
    Mutex::Autolock lock(mEventLock);
    if (mListener != NULL){
        mListener->asBinder()->unlinkToDeath(this);
    }
    if (listener != NULL) {
        listener->asBinder()->linkToDeath(this);
    }
    mListener = listener;
    return NO_ERROR;
}
@@ -576,4 +582,12 @@ status_t Drm::verify(Vector<uint8_t> const &sessionId,
    return mPlugin->verify(sessionId, keyId, message, signature, match);
}

void Drm::binderDied(const wp<IBinder> &the_late_who)
{
    delete mPlugin;
    mPlugin = NULL;
    closeFactory();
    mListener.clear();
}

}  // namespace android
+5 −1
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ namespace android {
struct DrmFactory;
struct DrmPlugin;

struct Drm : public BnDrm, public DrmPluginListener {
struct Drm : public BnDrm,
             public IBinder::DeathRecipient,
             public DrmPluginListener {
    Drm();
    virtual ~Drm();

@@ -115,6 +117,8 @@ struct Drm : public BnDrm, public DrmPluginListener {
                           Vector<uint8_t> const *sessionId,
                           Vector<uint8_t> const *data);

    virtual void binderDied(const wp<IBinder> &the_late_who);

private:
    mutable Mutex mLock;