]> git.ipfire.org Git - thirdparty/systemd.git/commit
pid1: properly remove references to the unit from gc queue during final cleanup
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 13 Feb 2018 22:57:43 +0000 (23:57 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Feb 2018 13:03:53 +0000 (14:03 +0100)
commit1bdf2790025e661e41894129eb390bb032b88585
tree720435b6f2bb5c9ef4dbc8b3cb2b590e5378ddf7
parenta946fa9bb968ac197d7a99970e27388b751dca94
pid1: properly remove references to the unit from gc queue during final cleanup

When various references to the unit were dropped during cleanup in unit_free(),
add_to_gc_queue() could be called on this unit. If the unit was previously in
the gc queue (at the time when unit_free() was called on it), this wouldn't
matter, because it'd have in_gc_queue still set even though it was already
removed from the queue. But if it wasn't set, then the unit could be added to
the queue. Then after unit_free() would deallocate the unit, we would be left
with a dangling pointer in gc_queue.

A unit could be added to the gc queue in two places called from unit_free():
in the job_install calls, and in unit_ref_unset(). The first was OK, because
it was above the LIST_REMOVE(gc_queue,...) call, but the second was not, because
it was after that. Move the all LIST_REMOVE() calls down.
src/core/unit.c