iv_event: Fix list handling race condition.
iv_event: Fix list handling race condition.

In __iv_event_run_pending_events(), we move all items on the list of
pending iv_event items onto a local list head while holding the list
mutex, and then process the elements on the local list without
holding the list mutex.

This is unsafe, as the iv_list_del_init() calls that we do on local
list items as we process them and that are done without holding the
list mutex can race against the add-to-the-list-if-not-already-on-it
logic done in iv_event_post() (which _is_ done under the list mutex).

Fix this by keeping the list mutex held while we delete iv_event
items off the local list, so that iv_event_post() only ever sees the
iv_event item either still fully on the list or fully deleted.

Signed-off-by: Lennert Buytenhek <8858498612e3a522354216649776e3032dcb7e5b@wantstofly.org>

buytenh/ivykis,buytenh/ivykis