代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 3c487e9d9b50e220f9eb32a020cbd9fd742d4405 Mon Sep 17 00:00:00 2001
From: Martin Kletzander <mkletzan@redhat.com>
Date: Tue, 27 Oct 2020 13:48:38 +0100
Subject: [PATCH 072/108] util: Avoid double free in virProcessSetAffinity
The cpu mask was free()'d immediately on any error and at the end of the
function, where it was expected that it would either error out and return or
goto another allocation if the code was to fail. However since commit
9514e24984ee the error path did not return in one new case which caused
double-free in such situation. In order to make the code more straightforward
just free the mask after it's been used even before checking the return code of
the call.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1819801
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 1f807631f402210d036ec4803e7adfefa222f786)
---
src/util/virprocess.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 141ebb54e0..c3f88d206b 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -450,6 +450,7 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
int numcpus = 1024;
size_t masklen;
cpu_set_t *mask;
+ int rv = -1;
/* Not only may the statically allocated cpu_set_t be too small,
* but there is no way to ask the kernel what size is large enough.
@@ -473,8 +474,10 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
CPU_SET_S(i, masklen, mask);
}
- if (sched_setaffinity(pid, masklen, mask) < 0) {
- CPU_FREE(mask);
+ rv = sched_setaffinity(pid, masklen, mask);
+ CPU_FREE(mask);
+
+ if (rv < 0) {
if (errno == EINVAL &&
numcpus < (1024 << 8)) { /* 262144 cpus ought to be enough for anyone */
numcpus = numcpus << 2;
@@ -484,7 +487,6 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
_("cannot set CPU affinity on process %d"), pid);
return -1;
}
- CPU_FREE(mask);
return 0;
}
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。