ryantimwilson / rpms / systemd

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