Skip to content

Commit

Permalink
cgroup: fix dereference before null check
Browse files Browse the repository at this point in the history
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 <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
  • Loading branch information
avagin authored and xemul committed Aug 7, 2014
1 parent ca94dc9 commit 1e0e837
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion proc_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e0e837

Please sign in to comment.