CWE-765

Multiple Unlocks of a Critical Resource

Medium

Description

The product unlocks a critical resource more times than intended, leading to an unexpected state in the system.

Potential Impact

How to Fix

Implementation

When locking and unlocking a resource, try to be sure that all control paths through the code in which the resource is locked one or more times correspond to exactly as many unlocks. If the product acquires a lock and then determines it is not able to perform its intended behavior, be sure to release the lock(s) before waiting for conditions to improve. Reacquire the lock(s) before trying again.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-765 vulnerabilities in your codebase.

Get Security Assessment