From f318f40415e9e2ff76aaef7b36fb88dedb6e784c Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 3 Oct 2012 17:29:04 +0400 Subject: [PATCH] pstree: Drop redundant nil test in prepare_pstree This as well releases pb entry on error path, not a big deal since we're exiting in case of error but still. Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- pstree.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pstree.c b/pstree.c index 6a61d6754..d3242c7ab 100644 --- a/pstree.c +++ b/pstree.c @@ -160,15 +160,18 @@ int prepare_pstree(void) parent = parent->parent; } - if (parent == NULL) - for_each_pstree_item(parent) + if (parent == NULL) { + for_each_pstree_item(parent) { if (parent->pid.virt == e->ppid) break; + } - if (parent == NULL) { - pr_err("Can't find a parent for %d", pi->pid.virt); - xfree(pi); - break; + if (parent == NULL) { + pr_err("Can't find a parent for %d", pi->pid.virt); + pstree_entry__free_unpacked(e, NULL); + xfree(pi); + goto err; + } } pi->parent = parent;