Blame SOURCES/0755-pid1-free-basic-unit-information-at-the-very-end-bef.patch

17b0f1
From 42a93a826cd726d1e4d3ea2c8cb347cec2f0dabe Mon Sep 17 00:00:00 2001
17b0f1
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
17b0f1
Date: Wed, 14 Feb 2018 00:01:05 +0100
17b0f1
Subject: [PATCH] pid1: free basic unit information at the very end, before
17b0f1
 freeing the unit
17b0f1
17b0f1
We would free stuff like the names of the unit first, and then recurse
17b0f1
into other structures to remove the unit from there. Technically this
17b0f1
was OK, since the code did not access the name, but this makes debugging
17b0f1
harder. And if any log messages are added in any of those functions, they
17b0f1
are likely to access u->id and such other basic information about the unit.
17b0f1
So let's move the removal of this "basic" information towards the end
17b0f1
of unit_free().
17b0f1
17b0f1
(cherry picked from commit a946fa9bb968ac197d7a99970e27388b751dca94)
17b0f1
17b0f1
Related: #1718953
17b0f1
---
17b0f1
 src/core/unit.c | 18 +++++++++---------
17b0f1
 1 file changed, 9 insertions(+), 9 deletions(-)
17b0f1
17b0f1
diff --git a/src/core/unit.c b/src/core/unit.c
17b0f1
index 2204be26d2..63f00acc0a 100644
17b0f1
--- a/src/core/unit.c
17b0f1
+++ b/src/core/unit.c
17b0f1
@@ -537,6 +537,15 @@ void unit_free(Unit *u) {
17b0f1
         set_remove(u->manager->failed_units, u);
17b0f1
         set_remove(u->manager->startup_units, u);
17b0f1
 
17b0f1
+        unit_unwatch_all_pids(u);
17b0f1
+
17b0f1
+        unit_ref_unset(&u->slice);
17b0f1
+        while (u->refs_by_target)
17b0f1
+                unit_ref_unset(u->refs_by_target);
17b0f1
+
17b0f1
+        condition_free_list(u->conditions);
17b0f1
+        condition_free_list(u->asserts);
17b0f1
+
17b0f1
         free(u->description);
17b0f1
         strv_free(u->documentation);
17b0f1
         free(u->fragment_path);
17b0f1
@@ -548,15 +557,6 @@ void unit_free(Unit *u) {
17b0f1
 
17b0f1
         set_free_free(u->names);
17b0f1
 
17b0f1
-        unit_unwatch_all_pids(u);
17b0f1
-
17b0f1
-        condition_free_list(u->conditions);
17b0f1
-        condition_free_list(u->asserts);
17b0f1
-
17b0f1
-        unit_ref_unset(&u->slice);
17b0f1
-        while (u->refs_by_target)
17b0f1
-                unit_ref_unset(u->refs_by_target);
17b0f1
-
17b0f1
         free(u);
17b0f1
 }
17b0f1