Skip to content

Commit

Permalink
net: lib: lwm2m: Fix missing mutex unlock
Browse files Browse the repository at this point in the history
lwm2m_engine_set() and lwm2m_engine_get() locks
the registry_lock mutex, but this is not unlocked
when setting or getting a time resource where the buffer
lengths are invalid resulting in an early return without
unlocking the mutex. This results in a deadlock when
attempting to lock the registry in another thread.

Signed-off-by: Steven Poon <[email protected]>
(cherry picked from commit 30b30c2)
  • Loading branch information
Steven Poon authored and github-actions[bot] committed Dec 2, 2024
1 parent cc3d24a commit 2918212
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ static int lwm2m_engine_set(const struct lwm2m_obj_path *path, const void *value
if (!lwm2m_validate_time_resource_lenghts(max_data_len, len)) {
LOG_ERR("Time Set: buffer length %u max data len %zu not supported", len,
max_data_len);
k_mutex_unlock(&registry_lock);
return -EINVAL;
}

Expand Down Expand Up @@ -928,6 +929,7 @@ static int lwm2m_engine_get(const struct lwm2m_obj_path *path, void *buf, uint16
if (!lwm2m_validate_time_resource_lenghts(data_len, buflen)) {
LOG_ERR("Time get buffer length %u data len %zu not supported",
buflen, data_len);
k_mutex_unlock(&registry_lock);
return -EINVAL;
}

Expand Down

0 comments on commit 2918212

Please sign in to comment.