Skip to content

Commit

Permalink
fix more leaks in audit_tree.c tag_chunk()
Browse files Browse the repository at this point in the history
Several leaks in audit_tree didn't get caught by commit
318b6d3, 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>
  • Loading branch information
Al Viro authored and Linus Torvalds committed Dec 19, 2009
1 parent 6f5d511 commit b4c30aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/audit_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b4c30aa

Please sign in to comment.