-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: modem_key_mgmt: enable CMEE _after_ taking lock
Wait with enabling CMEE until we have managed to acquire the lock. This prevents the following edge case: Thread A calls a function that acquires lock before enabling CMEE, like `read`. Thread B calls one that has the opposite (wrong?) order, like `clear`. 1. Thread A takes lock 2. Thread A enables CMEE (was_enabled = false) 3. Thread A happens to get scheduled out 4. Thread B enables CMEE (was_enabled = true) 5. Thread B blocks on trying to take lock 6. Thread A disables CMEE (since was_enabled == false) and releases lock 7. Thread B takes lock, tries to run command (but CMEE is disabled!) 8. Thread B doesn't try to disable CMEE since it was enabled before. Signed-off-by: Kamil Krzyzanowski <[email protected]>
- Loading branch information
Showing
1 changed file
with
27 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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