From 15aa0e6772f94170d26e236ef71482254e452427 Mon Sep 17 00:00:00 2001 From: Cong Lin Date: Fri, 27 Dec 2024 12:09:10 -0800 Subject: [PATCH] Allow key_session to be equal to oec_session when removing entitled key session In some rare cases when |oec_session| was already closed, |key_session| with the same session id will not exist any longer. This is a fix to allow such case to not return an error. Test: run opk tests Bug: 343093320 Change-Id: I3218145ee8c1047a5cc756560e448b178c2c7a93 --- libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index 9791626e..925462af 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -1258,7 +1258,13 @@ class Adapter { OEMCryptoResult RemoveEntitledKeySession(OEMCrypto_SESSION key_session) { LevelSession pair = GetSession(key_session); - if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION; + if (!pair.fcn) { + // If the entitlement session with the same session ID was closed before + // the entitled key session, GetSession() will return an empty pair. The + // entitled key session should already be released when its corresponding + // entitlement session was closed. In this case, simply return success. + return OEMCrypto_SUCCESS; + } if (pair.fcn->version < 16) return OEMCrypto_ERROR_NOT_IMPLEMENTED; if (pair.fcn->CreateEntitledKeySession == nullptr) return OEMCrypto_ERROR_NOT_IMPLEMENTED;