summaryrefslogtreecommitdiff
path: root/src/cgtop/cgtop.c
diff options
context:
space:
mode:
authorNaohiro Aota <naota@elisp.net>2016-04-29 00:41:50 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-28 11:41:50 -0400
commit80b2ab4bc00fe18ee4e9f1325bfc7cdd055c6466 (patch)
tree8613ff120eac0340d38bfb0e2724115bcb6a7260 /src/cgtop/cgtop.c
parent2b6c7113ad49d41c5fa40fef01b1fdcf23bca6f3 (diff)
cgtop: initialize `ours' to NULL properly (#3139)
Running cgtop on a system, which lacks expecting stat file, results in a segfault. For example, a system with blkio tree but without cfq io scheduler, lacks "blkio.io_service_bytes". When the targeting cgroup's file does not exist, process() returns 0 and also does not modify `*ret' value (which is `*ours'). As a result, callers of refresh_one() can have bogus pointer, which result in SEGV. This patch just properly initialize the variable to NULL.
Diffstat (limited to 'src/cgtop/cgtop.c')
-rw-r--r--src/cgtop/cgtop.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 9c0e82ebb3..14eb46c8db 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -362,7 +362,7 @@ static int refresh_one(
Group **ret) {
_cleanup_closedir_ DIR *d = NULL;
- Group *ours;
+ Group *ours = NULL;
int r;
assert(controller);