Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: lwm2m: Make LwM2M message allocation thread safe
The LwM2M message allocation was not thread safe, i. e. the message was acquired by setting the ctx pointer, and it was freed by clearing the entire message structure. If preemptive threads were enabled, and memset() clearing the message content was preempted, the message structure being currently zeroed migh've been allocated and initialized by some other thread. If the thread releasing the message resumed work, it would continue clearing the freshly allocated and initialized message structure. In order to prevent this, introduce a new global mutex, purely for message allocation/release. This will prevent reallocating the message during the release process. Since the mutex use is very simple, there's no risk of a deadlock. Signed-off-by: Robert Lubos <[email protected]>
- Loading branch information