Blame SOURCES/0801-unit-fix-potential-use-of-cgroup_path-after-free-whe.patch
|
|
ff2b41 |
From 98234ad6e16e868bd1fa3e4622c43a182fdee75c Mon Sep 17 00:00:00 2001
|
|
|
ff2b41 |
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
|
ff2b41 |
Date: Sat, 23 Nov 2019 13:37:02 +0100
|
|
|
ff2b41 |
Subject: [PATCH] unit: fix potential use of cgroup_path after free() when
|
|
|
ff2b41 |
freeing unit
|
|
|
ff2b41 |
|
|
|
ff2b41 |
Resolves: #1760149
|
|
|
ff2b41 |
---
|
|
|
ff2b41 |
src/core/cgroup.c | 3 +--
|
|
|
ff2b41 |
src/core/unit.c | 2 +-
|
|
|
ff2b41 |
2 files changed, 2 insertions(+), 3 deletions(-)
|
|
|
ff2b41 |
|
|
|
ff2b41 |
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
|
|
|
ff2b41 |
index 0ce265dbf4..9af8126957 100644
|
|
|
ff2b41 |
--- a/src/core/cgroup.c
|
|
|
ff2b41 |
+++ b/src/core/cgroup.c
|
|
|
ff2b41 |
@@ -874,8 +874,7 @@ void unit_destroy_cgroup_if_empty(Unit *u) {
|
|
|
ff2b41 |
|
|
|
ff2b41 |
hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
|
|
|
ff2b41 |
|
|
|
ff2b41 |
- free(u->cgroup_path);
|
|
|
ff2b41 |
- u->cgroup_path = NULL;
|
|
|
ff2b41 |
+ u->cgroup_path = mfree(u->cgroup_path);
|
|
|
ff2b41 |
u->cgroup_realized = false;
|
|
|
ff2b41 |
u->cgroup_realized_mask = 0;
|
|
|
ff2b41 |
}
|
|
|
ff2b41 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
ff2b41 |
index 294c9eb70f..0dc66203a4 100644
|
|
|
ff2b41 |
--- a/src/core/unit.c
|
|
|
ff2b41 |
+++ b/src/core/unit.c
|
|
|
ff2b41 |
@@ -515,7 +515,7 @@ void unit_free(Unit *u) {
|
|
|
ff2b41 |
|
|
|
ff2b41 |
if (u->cgroup_path) {
|
|
|
ff2b41 |
hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
|
|
|
ff2b41 |
- free(u->cgroup_path);
|
|
|
ff2b41 |
+ u->cgroup_path = mfree(u->cgroup_path);
|
|
|
ff2b41 |
}
|
|
|
ff2b41 |
|
|
|
ff2b41 |
set_remove(u->manager->failed_units, u);
|