diff options
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r-- | fs/kernfs/file.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8034706a7af8..5e9a80cfc3d8 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c | |||
@@ -484,6 +484,8 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) | |||
484 | 484 | ||
485 | ops = kernfs_ops(of->kn); | 485 | ops = kernfs_ops(of->kn); |
486 | rc = ops->mmap(of, vma); | 486 | rc = ops->mmap(of, vma); |
487 | if (rc) | ||
488 | goto out_put; | ||
487 | 489 | ||
488 | /* | 490 | /* |
489 | * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() | 491 | * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() |
@@ -608,6 +610,7 @@ static void kernfs_put_open_node(struct kernfs_node *kn, | |||
608 | static int kernfs_fop_open(struct inode *inode, struct file *file) | 610 | static int kernfs_fop_open(struct inode *inode, struct file *file) |
609 | { | 611 | { |
610 | struct kernfs_node *kn = file->f_path.dentry->d_fsdata; | 612 | struct kernfs_node *kn = file->f_path.dentry->d_fsdata; |
613 | struct kernfs_root *root = kernfs_root(kn); | ||
611 | const struct kernfs_ops *ops; | 614 | const struct kernfs_ops *ops; |
612 | struct kernfs_open_file *of; | 615 | struct kernfs_open_file *of; |
613 | bool has_read, has_write, has_mmap; | 616 | bool has_read, has_write, has_mmap; |
@@ -622,14 +625,16 @@ static int kernfs_fop_open(struct inode *inode, struct file *file) | |||
622 | has_write = ops->write || ops->mmap; | 625 | has_write = ops->write || ops->mmap; |
623 | has_mmap = ops->mmap; | 626 | has_mmap = ops->mmap; |
624 | 627 | ||
625 | /* check perms and supported operations */ | 628 | /* see the flag definition for details */ |
626 | if ((file->f_mode & FMODE_WRITE) && | 629 | if (root->flags & KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK) { |
627 | (!(inode->i_mode & S_IWUGO) || !has_write)) | 630 | if ((file->f_mode & FMODE_WRITE) && |
628 | goto err_out; | 631 | (!(inode->i_mode & S_IWUGO) || !has_write)) |
632 | goto err_out; | ||
629 | 633 | ||
630 | if ((file->f_mode & FMODE_READ) && | 634 | if ((file->f_mode & FMODE_READ) && |
631 | (!(inode->i_mode & S_IRUGO) || !has_read)) | 635 | (!(inode->i_mode & S_IRUGO) || !has_read)) |
632 | goto err_out; | 636 | goto err_out; |
637 | } | ||
633 | 638 | ||
634 | /* allocate a kernfs_open_file for the file */ | 639 | /* allocate a kernfs_open_file for the file */ |
635 | error = -ENOMEM; | 640 | error = -ENOMEM; |