984f77
From f307c633acd12d59800a760b1c45fad8c79b6f49 Mon Sep 17 00:00:00 2001
984f77
From: Yu Watanabe <watanabe.yu+github@gmail.com>
984f77
Date: Mon, 9 May 2022 00:56:05 +0900
984f77
Subject: [PATCH] core/unit: fix use-after-free
984f77
984f77
Fixes #23312.
984f77
984f77
(cherry picked from commit 734582830b58e000a26e18807ea277c18778573c)
984f77
984f77
Related: #2047373
984f77
---
984f77
 src/core/unit.c | 4 ++--
984f77
 1 file changed, 2 insertions(+), 2 deletions(-)
984f77
984f77
diff --git a/src/core/unit.c b/src/core/unit.c
984f77
index bd79578255..68affa2c0e 100644
984f77
--- a/src/core/unit.c
984f77
+++ b/src/core/unit.c
984f77
@@ -580,8 +580,8 @@ void unit_free(Unit *u) {
984f77
 
984f77
         unit_dequeue_rewatch_pids(u);
984f77
 
984f77
-        sd_bus_slot_unref(u->match_bus_slot);
984f77
-        sd_bus_track_unref(u->bus_track);
984f77
+        u->match_bus_slot = sd_bus_slot_unref(u->match_bus_slot);
984f77
+        u->bus_track = sd_bus_track_unref(u->bus_track);
984f77
         u->deserialized_refs = strv_free(u->deserialized_refs);
984f77
         u->pending_freezer_message = sd_bus_message_unref(u->pending_freezer_message);
984f77