The two most popular threading APIs, the Windows API and pthreads, both have the same basic way of locking and unlocking a mutex – that is, with two separate functions. This leaves the code prone to lock leak: the thread that acquired a lock doesn’t release it because an error occurred.

Lock leak is surprisingly common, and can be a source of deadlocks, among other things. The most common way to cause a lock leak is to not use RAII.

Not using RAII means you can cause a lock leak by simply using return without releasing the lock first. This is usually a violation of whatever coding standards are in place, and might occasionally be picked up by a static analysis tool, but it is much easier to avoid than that: simply always use RAII.