]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgtop: initialize `ours' to NULL properly (#3139)
authorNaohiro Aota <naota@elisp.net>
Thu, 28 Apr 2016 15:41:50 +0000 (00:41 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Apr 2016 15:41:50 +0000 (11:41 -0400)
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.

src/cgtop/cgtop.c

index 9c0e82ebb3e675c20f6bcdd64978e4b9ab664aab..14eb46c8dbd459e83cfb97af806545e1f88184af 100644 (file)
@@ -362,7 +362,7 @@ static int refresh_one(
                 Group **ret) {
 
         _cleanup_closedir_ DIR *d = NULL;
-        Group *ours;
+        Group *ours = NULL;
         int r;
 
         assert(controller);