[PATCH] kernel: audit_tree: resource management: need put_tree andgoto Err when failure occures
From: Chen Gang
Date: Fri Apr 12 2013 - 00:44:29 EST
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@xxxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/