Blame SOURCES/0122-test-fix-file-descriptor-leak-in-test-oomd-util.patch
|
|
8d419f |
From 9e37cb1855c8fc1667f7e404376070952c015788 Mon Sep 17 00:00:00 2001
|
|
|
8d419f |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
8d419f |
Date: Tue, 22 Feb 2022 21:38:15 +0900
|
|
|
8d419f |
Subject: [PATCH] test: fix file descriptor leak in test-oomd-util
|
|
|
8d419f |
|
|
|
8d419f |
Fixes an issue reported in #22576.
|
|
|
8d419f |
|
|
|
8d419f |
(cherry picked from commit 282696ce52471f5e3c963b9d98dbc89fba3a1fba)
|
|
|
8d419f |
Related: #2087652
|
|
|
8d419f |
---
|
|
|
8d419f |
src/oom/test-oomd-util.c | 5 ++++-
|
|
|
8d419f |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
8d419f |
|
|
|
8d419f |
diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c
|
|
|
8d419f |
index 265e77c0a2..0252ceecd7 100644
|
|
|
8d419f |
--- a/src/oom/test-oomd-util.c
|
|
|
8d419f |
+++ b/src/oom/test-oomd-util.c
|
|
|
8d419f |
@@ -5,6 +5,7 @@
|
|
|
8d419f |
#include "alloc-util.h"
|
|
|
8d419f |
#include "cgroup-setup.h"
|
|
|
8d419f |
#include "cgroup-util.h"
|
|
|
8d419f |
+#include "fd-util.h"
|
|
|
8d419f |
#include "fileio.h"
|
|
|
8d419f |
#include "fs-util.h"
|
|
|
8d419f |
#include "oomd-util.h"
|
|
|
8d419f |
@@ -13,6 +14,7 @@
|
|
|
8d419f |
#include "string-util.h"
|
|
|
8d419f |
#include "strv.h"
|
|
|
8d419f |
#include "tests.h"
|
|
|
8d419f |
+#include "tmpfile-util.h"
|
|
|
8d419f |
|
|
|
8d419f |
static int fork_and_sleep(unsigned sleep_min) {
|
|
|
8d419f |
usec_t n, timeout, ts;
|
|
|
8d419f |
@@ -244,12 +246,13 @@ static void test_oomd_update_cgroup_contexts_between_hashmaps(void) {
|
|
|
8d419f |
|
|
|
8d419f |
static void test_oomd_system_context_acquire(void) {
|
|
|
8d419f |
_cleanup_(unlink_tempfilep) char path[] = "/oomdgetsysctxtestXXXXXX";
|
|
|
8d419f |
+ _cleanup_close_ int fd = -1;
|
|
|
8d419f |
OomdSystemContext ctx;
|
|
|
8d419f |
|
|
|
8d419f |
if (geteuid() != 0)
|
|
|
8d419f |
return (void) log_tests_skipped("not root");
|
|
|
8d419f |
|
|
|
8d419f |
- assert_se(mkstemp(path));
|
|
|
8d419f |
+ assert_se((fd = mkostemp_safe(path)) >= 0);
|
|
|
8d419f |
|
|
|
8d419f |
assert_se(oomd_system_context_acquire("/verylikelynonexistentpath", &ctx) == -ENOENT);
|
|
|
8d419f |
|