From 1e0e83701f441852cccae40c97135884aff942b4 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Wed, 6 Aug 2014 17:13:00 +0400 Subject: [PATCH] cgroup: fix dereference before null check Coverity: 1230177 Dereference before null check There may be a null pointer dereference, or else the comparison against null is unnecessary. In parse_task_cgroup: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476) Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- proc_parse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proc_parse.c b/proc_parse.c index 3da54454e5..10285f46cf 100644 --- a/proc_parse.c +++ b/proc_parse.c @@ -1598,7 +1598,8 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n) * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope */ name = strchr(buf, ':') + 1; - path = strchr(name, ':'); + if (name) + path = strchr(name, ':'); if (!name || !path) { pr_err("Failed parsing cgroup %s\n", buf); xfree(ncc);