All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/audit_tree.c: tree will memory leak when failure occurs for audit_trim_trees()
@ 2013-04-19  9:39 Chen Gang
  2013-04-22 23:04 ` Andrew Morton
  0 siblings, 1 reply; 15+ messages in thread
From: Chen Gang @ 2013-04-19  9:39 UTC (permalink / raw)
  To: Eric Paris, Al Viro; +Cc: Andrew Morton, linux-kernel


in audit_trim_trees(), has called get_tree() before failure occurs,
so need also call put_tree after go to skip_it:

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/audit_tree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 642a89c..de46ec0 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -617,10 +617,10 @@ void audit_trim_trees(void)
 		}
 		spin_unlock(&hash_lock);
 		trim_marked(tree);
-		put_tree(tree);
 		drop_collected_mounts(root_mnt);
 skip_it:
 		mutex_lock(&audit_filter_mutex);
+		put_tree(tree);
 	}
 	list_del(&cursor);
 	mutex_unlock(&audit_filter_mutex);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] kernel: audit_tree: resource management: need put_tree and goto Err when failure occures
@ 2013-04-12  4:43 Chen Gang
  2013-04-16  7:35 ` Chen Gang
  0 siblings, 1 reply; 15+ messages in thread
From: Chen Gang @ 2013-04-12  4:43 UTC (permalink / raw)
  To: Eric Paris, Al Viro, linux-kernel


  since "normally audit_add_tree_rule() will free it on failure",
  need free it completely, when failure occures.

    need additional put_tree before return, since get_tree was called.
    always need goto error processing area for list_del_init.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/audit_tree.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 642a89c..3729d49 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -694,13 +694,15 @@ int audit_add_tree_rule(struct audit_krule *rule)
 		spin_unlock(&hash_lock);
 	} else {
 		trim_marked(tree);
+		put_tree(tree);
 		goto Err;
 	}
 
 	mutex_lock(&audit_filter_mutex);
 	if (list_empty(&rule->rlist)) {
 		put_tree(tree);
-		return -ENOENT;
+		err = -ENOENT;
+		got Err1;
 	}
 	rule->tree = tree;
 	put_tree(tree);
@@ -708,6 +710,7 @@ int audit_add_tree_rule(struct audit_krule *rule)
 	return 0;
 Err:
 	mutex_lock(&audit_filter_mutex);
+Err1:
 	list_del_init(&tree->list);
 	list_del_init(&tree->rules);
 	put_tree(tree);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-05-13  2:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-19  9:39 [PATCH] kernel/audit_tree.c: tree will memory leak when failure occurs for audit_trim_trees() Chen Gang
2013-04-22 23:04 ` Andrew Morton
2013-04-23  1:46   ` Chen Gang
2013-05-06  7:41   ` [PATCH kernel-next] kernel/audit_tree.c: fix the original version merging issue for put_tree() Chen Gang
2013-05-09 12:53   ` [PATCH v2] kernel: audit_tree: resource management: need put_tree and goto Err when failure occures Chen Gang
2013-05-09 20:11     ` Andrew Morton
2013-05-10  2:08       ` Chen Gang
2013-05-10  9:50         ` Chen Gang
2013-05-10 11:29           ` Chen Gang
2013-05-13  2:54             ` Chen Gang
  -- strict thread matches above, loose matches on Subject: below --
2013-04-12  4:43 [PATCH] " Chen Gang
2013-04-16  7:35 ` Chen Gang
2013-04-17  4:04   ` [PATCH v2] " Chen Gang
2013-04-17 20:07     ` Andrew Morton
2013-04-18  1:19       ` Chen Gang F T
2013-04-20  7:31         ` Chen Gang
2013-04-23  3:51           ` Chen Gang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.