From: Chen Gang <gang.chen@asianux.com> Date: Mon, 8 Jul 2013 22:59:38 +0000 (-0700) Subject: kernel/auditfilter.c: fix leak in audit_add_rule() error path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2f992ee85aaa7dfd2bda43efe4493af1e108d054;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git kernel/auditfilter.c: fix leak in audit_add_rule() error path If both 'tree' and 'watch' are valid we must call audit_put_tree(), just like the preceding code within audit_add_rule(). Signed-off-by: Chen Gang <gang.chen@asianux.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Eric Paris <eparis@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 0ee9eff866d6..3d15c66b7f0b 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c @@ -865,6 +865,12 @@ static inline int audit_add_rule(struct audit_entry *entry) err = audit_add_watch(&entry->rule, &list); if (err) { mutex_unlock(&audit_filter_mutex); + /* + * normally audit_add_tree_rule() will free it + * on failure + */ + if (tree) + audit_put_tree(tree); goto error; } }