diff options
| author | Al Viro <viro@ZenIV.linux.org.uk> | 2009-12-19 11:03:30 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-19 12:27:43 -0500 |
| commit | b4c30aad39805902cf5b855aa8a8b22d728ad057 (patch) | |
| tree | 77aade9b02f1c7b0d2e92cdee9ce2403121f4a23 /kernel | |
| parent | 6f5d51148921c242680a7a1d9913384a30ab3cbe (diff) | |
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.c | 9 |
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) | |||
| 373 | for (n = 0; n < old->count; n++) { | 373 | for (n = 0; n < old->count; n++) { |
| 374 | if (old->owners[n].owner == tree) { | 374 | if (old->owners[n].owner == tree) { |
| 375 | spin_unlock(&hash_lock); | 375 | spin_unlock(&hash_lock); |
| 376 | put_inotify_watch(watch); | 376 | put_inotify_watch(&old->watch); |
| 377 | return 0; | 377 | return 0; |
| 378 | } | 378 | } |
| 379 | } | 379 | } |
| 380 | spin_unlock(&hash_lock); | 380 | spin_unlock(&hash_lock); |
| 381 | 381 | ||
| 382 | chunk = alloc_chunk(old->count + 1); | 382 | chunk = alloc_chunk(old->count + 1); |
| 383 | if (!chunk) | 383 | if (!chunk) { |
| 384 | put_inotify_watch(&old->watch); | ||
| 384 | return -ENOMEM; | 385 | return -ENOMEM; |
| 386 | } | ||
| 385 | 387 | ||
| 386 | mutex_lock(&inode->inotify_mutex); | 388 | mutex_lock(&inode->inotify_mutex); |
| 387 | if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) { | 389 | if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) { |
| @@ -425,7 +427,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) | |||
| 425 | spin_unlock(&hash_lock); | 427 | spin_unlock(&hash_lock); |
| 426 | inotify_evict_watch(&old->watch); | 428 | inotify_evict_watch(&old->watch); |
| 427 | mutex_unlock(&inode->inotify_mutex); | 429 | mutex_unlock(&inode->inotify_mutex); |
| 428 | put_inotify_watch(&old->watch); | 430 | put_inotify_watch(&old->watch); /* pair to inotify_find_watch */ |
| 431 | put_inotify_watch(&old->watch); /* and kill it */ | ||
| 429 | return 0; | 432 | return 0; |
| 430 | } | 433 | } |
| 431 | 434 | ||
