c313de
From c627fa58c17960e5eed999049bf966b5ea952c3b Mon Sep 17 00:00:00 2001
c313de
Message-Id: <c627fa58c17960e5eed999049bf966b5ea952c3b@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Fri, 30 Aug 2019 16:35:33 +0200
c313de
Subject: [PATCH] vircgroupv2: fix abort in VIR_AUTOFREE
c313de
c313de
Introduced by commit <c854e0bd33c7a5afb04a36465bf04f861b2efef5> that
c313de
tried to fix an issue where we would fail to parse values from files.
c313de
c313de
We cannot change the original pointer that is going to be used by
c313de
VIR_AUTOFREE.
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1747440
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Acked-by: Peter Krempa <pkrempa@redhat.com>
c313de
(cherry picked from commit 9a99b01f8d3b2be491f9f8412c6f894d30d7e2fe)
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <c9be614c3648b2901481f257ba1af3fcd8fe7e76.1567175708.git.phrdina@redhat.com>
c313de
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c313de
---
c313de
 src/util/vircgroupv2.c | 6 ++++--
c313de
 1 file changed, 4 insertions(+), 2 deletions(-)
c313de
c313de
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c313de
index e31a2d1121..e7b9093754 100644
c313de
--- a/src/util/vircgroupv2.c
c313de
+++ b/src/util/vircgroupv2.c
c313de
@@ -848,6 +848,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
c313de
     VIR_AUTOFREE(char *) path = NULL;
c313de
     VIR_AUTOFREE(char *) str = NULL;
c313de
     VIR_AUTOFREE(char *) value = NULL;
c313de
+    char *tmp;
c313de
 
c313de
     if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
c313de
                                     "io.weight", &path) < 0) {
c313de
@@ -868,7 +869,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
c313de
 
c313de
     if (!str) {
c313de
         *weight = 0;
c313de
-    } else if (virStrToLong_ui(str, &str, 10, weight) < 0) {
c313de
+    } else if (virStrToLong_ui(str, &tmp, 10, weight) < 0) {
c313de
         virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
                        _("Unable to parse '%s' as an integer"),
c313de
                        str);
c313de
@@ -1575,6 +1576,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
c313de
                           long long *cfs_quota)
c313de
 {
c313de
     VIR_AUTOFREE(char *) str = NULL;
c313de
+    char *tmp;
c313de
 
c313de
     if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU,
c313de
                              "cpu.max", &str) < 0) {
c313de
@@ -1586,7 +1588,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
c313de
         return 0;
c313de
     }
c313de
 
c313de
-    if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) {
c313de
+    if (virStrToLong_ll(str, &tmp, 10, cfs_quota) < 0) {
c313de
         virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
                        _("Failed to parse value '%s' from cpu.max."), str);
c313de
         return -1;
c313de
-- 
c313de
2.23.0
c313de