Skip to content

Fix return without unlocking thd_engine_mutex#528

Merged
spandruvada merged 1 commit intointel:masterfrom
ColinIanKing:fix-locking-issue
Mar 3, 2026
Merged

Fix return without unlocking thd_engine_mutex#528
spandruvada merged 1 commit intointel:masterfrom
ColinIanKing:fix-locking-issue

Conversation

@ColinIanKing
Copy link
Contributor

A recent set of checks on path don't unlock thd_engine_mutex on error return exits from cthd_engine::user_add_senso leading to locking issues.

Fix this by performing the lock on thd_engine_mutex after the sanity checks on path to avoid the locking issue and to defer locking to the latest point where it is required.

Fixes: d74be68 ("Check for start path instead of anywhere")

A recent set of checks on path don't unlock thd_engine_mutex on error
return exits from cthd_engine::user_add_senso leading to locking issues.

Fix this by performing the lock on thd_engine_mutex after the sanity
checks on path to avoid the locking issue and to defer locking to
the latest point where it is required.

Fixes: d74be68 ("Check for start path instead of anywhere")

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

if (path.empty())
return THD_ERROR;
pthread_mutex_unlock(&thd_engine_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to unlock here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was locked before as it is running on a dfferent thread than the thermald controls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand on the intended locking of cthd_engine::user_add_sensor? I understand that sensors is protected by thd_engine_mutex. Tracing the call stack, thd_dbus_interface_add_sensor calls user_add_sensor yet I don't see this or the DBUS-related methods holding the lock. Is the lock intended to be held before calling this function? Also is it correct to just unlock without returning?

@spandruvada spandruvada merged commit e8c6ea8 into intel:master Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants