RDKEMW-21466: crash Observed in Vipa while zapping Linear channels#205
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent a use-after-free crash during rapid linear channel zaps by introducing a lifecycle guard on DrmSession and applying it around GStreamer decrypt operations, while also ensuring session teardown attempts to wait for in-flight decrypt work to finish.
Changes:
- Added
DrmSessionlifecycle-guard APIs (AcquireForUse(),ReleaseAfterUse(),PrepareForDestruction()) backed by a mutex/condition variable. - Wrapped GStreamer decrypt calls with acquire/release guard calls to avoid decrypt running concurrently with session teardown.
- Updated
DrmSessionManagerdeletion paths to callPrepareForDestruction()before deleting sessions; adjusted sink caps handling to avoid using freed caps after unlocking.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| gst-plugins/drm/gst/gstcdmidecryptor.cpp | Guards decrypt calls with AcquireForUse()/ReleaseAfterUse() and adjusts sink caps refcounting around unlock. |
| drm/DrmSessionManager.cpp | Calls PrepareForDestruction() before deleting DrmSession instances in multiple teardown/eviction paths. |
| drm/DrmSession.h | Adds lifecycle guard members and declares new lifecycle guard methods. |
| drm/DrmSession.cpp | Implements lifecycle guard methods using mutex/condition_variable and bounded wait. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sankarimuthu
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a lifecycle guard to DrmSession — three new methods (AcquireForUse(), ReleaseAfterUse(), PrepareForDestruction()) using a mutex + condition variable to track in-flight decrypt operations and block deletion until they finish.
Guards every decrypt() call in the GStreamer decryptor plugin (gstcdmidecryptor.cpp) with AcquireForUse() / ReleaseAfterUse(), so the session can't be freed mid-operation.
Calls PrepareForDestruction() before every delete in DrmSessionManager (session clearing, slot reuse/eviction), ensuring any in-flight decrypt drains first .
Minor fix: a sinkCaps reference-counting tweak to avoid accessing freed caps after unlocking the mutex.