kernel: k_work: k_work_init() should initialize all fields
k_work_init() was not initializing all fields in the k_work struct. Mainly, the atomic_clear_bit() function call was reading a possibly uninitialized value, clearing a bit, and assigning it back to the `flags` member. The `_reserved` member was never initialized. With the struct now initialized with the _K_WORK_INITIALIZER() macro, initialization is consistent regardless of how a `struct k_work` is initialized. This fixes the Valgrind issues found in #7478. Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
parent
a026b9eaca
commit
0e23ad889e
1 changed files with 1 additions and 2 deletions
|
@ -2584,8 +2584,7 @@ extern struct k_work_q k_sys_work_q;
|
|||
*/
|
||||
static inline void k_work_init(struct k_work *work, k_work_handler_t handler)
|
||||
{
|
||||
atomic_clear_bit(work->flags, K_WORK_STATE_PENDING);
|
||||
work->handler = handler;
|
||||
*work = (struct k_work)_K_WORK_INITIALIZER(handler);
|
||||
_k_object_init(work);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue