richardphibel / rpms / systemd

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