Skip to content

Commit b4c30aa

Browse files
Al Virotorvalds
authored andcommitted
fix more leaks in audit_tree.c tag_chunk()
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>
1 parent 6f5d511 commit b4c30aa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎kernel/audit_tree.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,17 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
373373
for (n = 0; n < old->count; n++) {
374374
if (old->owners[n].owner == tree) {
375375
spin_unlock(&hash_lock);
376-
put_inotify_watch(watch);
376+
put_inotify_watch(&old->watch);
377377
return 0;
378378
}
379379
}
380380
spin_unlock(&hash_lock);
381381

382382
chunk = alloc_chunk(old->count + 1);
383-
if (!chunk)
383+
if (!chunk) {
384+
put_inotify_watch(&old->watch);
384385
return -ENOMEM;
386+
}
385387

386388
mutex_lock(&inode->inotify_mutex);
387389
if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
@@ -425,7 +427,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
425427
spin_unlock(&hash_lock);
426428
inotify_evict_watch(&old->watch);
427429
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 */
429432
return 0;
430433
}
431434

0 commit comments

Comments
 (0)