2023-07-14 03:16:39 +00:00
|
|
|
From b2c83183e7ace5049bab265ec3084335165ff570 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: vegbir <yangjiaqi16@huawei.com>
|
|
|
|
|
Date: Wed, 12 Jul 2023 07:07:16 +0000
|
|
|
|
|
Subject: [PATCH 04/16] fix memory leak
|
2021-11-27 15:55:20 +08:00
|
|
|
|
2023-07-14 03:16:39 +00:00
|
|
|
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
2021-11-27 15:55:20 +08:00
|
|
|
---
|
|
|
|
|
src/proc_fuse.c | 8 +++++++-
|
|
|
|
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
|
|
|
2020-08-28 15:17:28 +08:00
|
|
|
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
2023-07-14 03:16:39 +00:00
|
|
|
index 4503373..c615e8e 100644
|
2020-08-28 15:17:28 +08:00
|
|
|
--- a/src/proc_fuse.c
|
|
|
|
|
+++ b/src/proc_fuse.c
|
2023-07-14 03:16:39 +00:00
|
|
|
@@ -304,6 +304,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap)
|
2020-08-28 15:17:28 +08:00
|
|
|
return log_error_errno(0, ENOMEM, "Failed to allocate memory");
|
|
|
|
|
|
|
|
|
|
retlimit = get_memlimit(copy, swap);
|
|
|
|
|
+ if (retlimit == 0)
|
2021-11-27 15:55:20 +08:00
|
|
|
+ return 0;
|
2020-08-28 15:17:28 +08:00
|
|
|
|
2021-11-27 15:55:20 +08:00
|
|
|
/*
|
|
|
|
|
* If the cgroup doesn't start with / (probably won't happen), dirname()
|
2023-07-14 03:16:39 +00:00
|
|
|
@@ -409,6 +411,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
|
2020-08-28 15:17:28 +08:00
|
|
|
prune_init_slice(cgroup);
|
|
|
|
|
|
|
|
|
|
memlimit = get_min_memlimit(cgroup, false);
|
|
|
|
|
+ if (memlimit == 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
|
|
ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str);
|
|
|
|
|
if (ret < 0)
|
2023-07-14 03:16:39 +00:00
|
|
|
@@ -1442,6 +1446,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
2020-08-28 15:17:28 +08:00
|
|
|
return read_file_fuse("/proc/meminfo", buf, size, d);
|
|
|
|
|
|
|
|
|
|
memlimit = get_min_memlimit(cgroup, false);
|
|
|
|
|
+ if (memlimit == 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Following values are allowed to fail, because swapaccount might be
|
2023-07-14 03:16:39 +00:00
|
|
|
@@ -1456,9 +1462,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
|
2020-08-28 15:17:28 +08:00
|
|
|
|
|
|
|
|
memusage /= 1024;
|
|
|
|
|
memlimit /= 1024;
|
|
|
|
|
+ char *printme, lbuf[100];
|
|
|
|
|
while (getline(&line, &linelen, f) != -1) {
|
|
|
|
|
ssize_t l;
|
|
|
|
|
- char *printme, lbuf[100];
|
|
|
|
|
|
|
|
|
|
memset(lbuf, 0, 100);
|
|
|
|
|
if (startswith(line, "MemTotal:")) {
|
2021-11-27 15:55:20 +08:00
|
|
|
--
|
2023-07-14 03:16:39 +00:00
|
|
|
2.41.0
|
2021-11-27 15:55:20 +08:00
|
|
|
|