teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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