Skip to content

Commit 9c63873

Browse files
Steven Poondkalowsk
authored andcommitted
net: lib: lwm2m: Fix missing mutex unlock
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)
1 parent bd1db48 commit 9c63873

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

subsys/net/lib/lwm2m/lwm2m_registry.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ static int lwm2m_engine_set(const struct lwm2m_obj_path *path, const void *value
648648
if (!lwm2m_validate_time_resource_lenghts(max_data_len, len)) {
649649
LOG_ERR("Time Set: buffer length %u max data len %zu not supported", len,
650650
max_data_len);
651+
k_mutex_unlock(&registry_lock);
651652
return -EINVAL;
652653
}
653654

@@ -924,6 +925,7 @@ static int lwm2m_engine_get(const struct lwm2m_obj_path *path, void *buf, uint16
924925
if (!lwm2m_validate_time_resource_lenghts(data_len, buflen)) {
925926
LOG_ERR("Time get buffer length %u data len %zu not supported",
926927
buflen, data_len);
928+
k_mutex_unlock(&registry_lock);
927929
return -EINVAL;
928930
}
929931

0 commit comments

Comments
 (0)