|
@@ -441,7 +441,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
|
|
|
static int f2fs_file_open(struct inode *inode, struct file *filp)
|
|
|
{
|
|
|
int ret = generic_file_open(inode, filp);
|
|
|
- struct inode *dir = filp->f_path.dentry->d_parent->d_inode;
|
|
|
+ struct dentry *dir;
|
|
|
|
|
|
if (!ret && f2fs_encrypted_inode(inode)) {
|
|
|
ret = fscrypt_get_encryption_info(inode);
|
|
@@ -450,9 +450,13 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)
|
|
|
if (!fscrypt_has_encryption_key(inode))
|
|
|
return -ENOKEY;
|
|
|
}
|
|
|
- if (f2fs_encrypted_inode(dir) &&
|
|
|
- !fscrypt_has_permitted_context(dir, inode))
|
|
|
+ dir = dget_parent(file_dentry(filp));
|
|
|
+ if (f2fs_encrypted_inode(d_inode(dir)) &&
|
|
|
+ !fscrypt_has_permitted_context(d_inode(dir), inode)) {
|
|
|
+ dput(dir);
|
|
|
return -EPERM;
|
|
|
+ }
|
|
|
+ dput(dir);
|
|
|
return ret;
|
|
|
}
|
|
|
|