summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2009-12-19 17:03:30 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-19 18:27:43 +0100
commitb4c30aad39805902cf5b855aa8a8b22d728ad057 (patch)
tree77aade9b02f1c7b0d2e92cdee9ce2403121f4a23 /kernel
parentfix braindamage in audit_tree.c untag_chunk() (diff)
downloadlinux-b4c30aad39805902cf5b855aa8a8b22d728ad057.tar.xz
linux-b4c30aad39805902cf5b855aa8a8b22d728ad057.zip
fix more leaks in audit_tree.c tag_chunk()
Several leaks in audit_tree didn't get caught by commit 318b6d3d7ddbcad3d6867e630711b8a705d873d7, including the leak on normal exit in case of multiple rules refering to the same chunk. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/audit_tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index b36aa9651ba2..4b05bd9479db 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -373,15 +373,17 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
for (n = 0; n < old->count; n++) {
if (old->owners[n].owner == tree) {
spin_unlock(&hash_lock);
- put_inotify_watch(watch);
+ put_inotify_watch(&old->watch);
return 0;
}
}
spin_unlock(&hash_lock);
chunk = alloc_chunk(old->count + 1);
- if (!chunk)
+ if (!chunk) {
+ put_inotify_watch(&old->watch);
return -ENOMEM;
+ }
mutex_lock(&inode->inotify_mutex);
if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
@@ -425,7 +427,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
spin_unlock(&hash_lock);
inotify_evict_watch(&old->watch);
mutex_unlock(&inode->inotify_mutex);
- put_inotify_watch(&old->watch);
+ put_inotify_watch(&old->watch); /* pair to inotify_find_watch */
+ put_inotify_watch(&old->watch); /* and kill it */
return 0;
}