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