From 139980a5969bf851feda873fe918f34bee8fc055 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 6 Dec 2024 10:52:00 +0100 Subject: [PATCH] zramctl: fix typo and memory leak Signed-off-by: Karel Zak --- sys-utils/zramctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c index 335db01ba..75fdfa334 100644 --- a/sys-utils/zramctl.c +++ b/sys-utils/zramctl.c @@ -349,7 +349,6 @@ static int get_mm_stat(struct zram *z, { struct path_cxt *sysfs; const char *name; - char *str = NULL; uint64_t num; assert(idx < ARRAY_SIZE(mm_stat_names)); @@ -361,6 +360,7 @@ static int get_mm_stat(struct zram *z, /* Linux >= 4.1 uses /sys/block/zram/mm_stat */ if (!z->mm_stat && !z->mm_stat_probed) { + char *str = NULL; if (ul_path_read_string(sysfs, &str, "mm_stat") > 0 && str) { z->mm_stat = strv_split(str, " "); @@ -390,7 +390,7 @@ static int get_mm_stat(struct zram *z, /* Linux < 4.1 uses /sys/block/zram/ */ name = mm_stat_names[idx]; if (re_str && bytes) - ul_path_read_string(sysfs, &str, name); + ul_path_read_string(sysfs, re_str, name); if ((re_str && !bytes) || re_num) { int rc = ul_path_read_u64(sysfs, &num, name); -- 2.47.2