mirror of
https://github.com/joel16/android_kernel_sony_msm8994.git
synced 2025-03-04 03:10:06 +00:00
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>
This commit is contained in:
parent
6f5d511489
commit
b4c30aad39
@ -373,15 +373,17 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
|
|||||||
for (n = 0; n < old->count; n++) {
|
for (n = 0; n < old->count; n++) {
|
||||||
if (old->owners[n].owner == tree) {
|
if (old->owners[n].owner == tree) {
|
||||||
spin_unlock(&hash_lock);
|
spin_unlock(&hash_lock);
|
||||||
put_inotify_watch(watch);
|
put_inotify_watch(&old->watch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&hash_lock);
|
spin_unlock(&hash_lock);
|
||||||
|
|
||||||
chunk = alloc_chunk(old->count + 1);
|
chunk = alloc_chunk(old->count + 1);
|
||||||
if (!chunk)
|
if (!chunk) {
|
||||||
|
put_inotify_watch(&old->watch);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_lock(&inode->inotify_mutex);
|
mutex_lock(&inode->inotify_mutex);
|
||||||
if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
|
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);
|
spin_unlock(&hash_lock);
|
||||||
inotify_evict_watch(&old->watch);
|
inotify_evict_watch(&old->watch);
|
||||||
mutex_unlock(&inode->inotify_mutex);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user