• Jukka Laitinen's avatar
    Fix memory corruption when work queue is being deleted · d1c09ec3
    Jukka Laitinen authored
    When the last WorkItem is deleted, it is removed from a work queue and the
    queue is being stopped. But, the queue itself might get deleted in the middle,
    in a higher priority thread than where the WorkItem deletion was performed from
    If the WorkQueue::Detach accesses the member variables after this, there is memory
    This happens in particular when launching i2c or spi devices in
    - The "initializer" is deleted when the instance is not found and the iterator
      while loop continues.
    - The workqueue is deleted in the middle of "initializer" deletion when the
      WorkQueueRunner returns.
    This prevents deletion of the WorkQueue before the Detach has been finished,
    in the specific case that the ::Detach triggers the deletion
    Signed-off-by: default avatarJukka Laitinen <jukkax@ssrc.tii.ae>