Commit 542ce7a9bc6b3838832ae0f4f8de30c667af8ff3
Committed by
Al Viro
1 parent
6d0b5456e1
Exists in
master
and in
7 other branches
cachefiles: use path_get instead of lone dget
Dentry references should not be acquired without a corresponding vfsmount ref. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 14 additions and 12 deletions Side-by-side Diff
fs/cachefiles/daemon.c
... | ... | @@ -553,7 +553,7 @@ |
553 | 553 | static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args) |
554 | 554 | { |
555 | 555 | struct fs_struct *fs; |
556 | - struct dentry *dir; | |
556 | + struct path path; | |
557 | 557 | const struct cred *saved_cred; |
558 | 558 | int ret; |
559 | 559 | |
560 | 560 | |
561 | 561 | |
562 | 562 | |
563 | 563 | |
... | ... | @@ -575,22 +575,23 @@ |
575 | 575 | /* extract the directory dentry from the cwd */ |
576 | 576 | fs = current->fs; |
577 | 577 | read_lock(&fs->lock); |
578 | - dir = dget(fs->pwd.dentry); | |
578 | + path = fs->pwd; | |
579 | + path_get(&path); | |
579 | 580 | read_unlock(&fs->lock); |
580 | 581 | |
581 | - if (!S_ISDIR(dir->d_inode->i_mode)) | |
582 | + if (!S_ISDIR(path.dentry->d_inode->i_mode)) | |
582 | 583 | goto notdir; |
583 | 584 | |
584 | 585 | cachefiles_begin_secure(cache, &saved_cred); |
585 | - ret = cachefiles_cull(cache, dir, args); | |
586 | + ret = cachefiles_cull(cache, path.dentry, args); | |
586 | 587 | cachefiles_end_secure(cache, saved_cred); |
587 | 588 | |
588 | - dput(dir); | |
589 | + path_put(&path); | |
589 | 590 | _leave(" = %d", ret); |
590 | 591 | return ret; |
591 | 592 | |
592 | 593 | notdir: |
593 | - dput(dir); | |
594 | + path_put(&path); | |
594 | 595 | kerror("cull command requires dirfd to be a directory"); |
595 | 596 | return -ENOTDIR; |
596 | 597 | |
... | ... | @@ -629,7 +630,7 @@ |
629 | 630 | static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args) |
630 | 631 | { |
631 | 632 | struct fs_struct *fs; |
632 | - struct dentry *dir; | |
633 | + struct path path; | |
633 | 634 | const struct cred *saved_cred; |
634 | 635 | int ret; |
635 | 636 | |
636 | 637 | |
637 | 638 | |
638 | 639 | |
639 | 640 | |
... | ... | @@ -651,22 +652,23 @@ |
651 | 652 | /* extract the directory dentry from the cwd */ |
652 | 653 | fs = current->fs; |
653 | 654 | read_lock(&fs->lock); |
654 | - dir = dget(fs->pwd.dentry); | |
655 | + path = fs->pwd; | |
656 | + path_get(&path); | |
655 | 657 | read_unlock(&fs->lock); |
656 | 658 | |
657 | - if (!S_ISDIR(dir->d_inode->i_mode)) | |
659 | + if (!S_ISDIR(path.dentry->d_inode->i_mode)) | |
658 | 660 | goto notdir; |
659 | 661 | |
660 | 662 | cachefiles_begin_secure(cache, &saved_cred); |
661 | - ret = cachefiles_check_in_use(cache, dir, args); | |
663 | + ret = cachefiles_check_in_use(cache, path.dentry, args); | |
662 | 664 | cachefiles_end_secure(cache, saved_cred); |
663 | 665 | |
664 | - dput(dir); | |
666 | + path_put(&path); | |
665 | 667 | //_leave(" = %d", ret); |
666 | 668 | return ret; |
667 | 669 | |
668 | 670 | notdir: |
669 | - dput(dir); | |
671 | + path_put(&path); | |
670 | 672 | kerror("inuse command requires dirfd to be a directory"); |
671 | 673 | return -ENOTDIR; |
672 | 674 |