Commit b4c30aad39805902cf5b855aa8a8b22d728ad057

Authored by Al Viro
Committed by Linus Torvalds
1 parent 6f5d511489

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>

Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff

... ... @@ -373,15 +373,17 @@
373 373 for (n = 0; n < old->count; n++) {
374 374 if (old->owners[n].owner == tree) {
375 375 spin_unlock(&hash_lock);
376   - put_inotify_watch(watch);
  376 + put_inotify_watch(&old->watch);
377 377 return 0;
378 378 }
379 379 }
380 380 spin_unlock(&hash_lock);
381 381  
382 382 chunk = alloc_chunk(old->count + 1);
383   - if (!chunk)
  383 + if (!chunk) {
  384 + put_inotify_watch(&old->watch);
384 385 return -ENOMEM;
  386 + }
385 387  
386 388 mutex_lock(&inode->inotify_mutex);
387 389 if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
... ... @@ -425,7 +427,8 @@
425 427 spin_unlock(&hash_lock);
426 428 inotify_evict_watch(&old->watch);
427 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 432 return 0;
430 433 }
431 434