diff options
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r-- | fs/ext4/file.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 6659e216385e..fa2208bae2e1 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -329,7 +329,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
329 | struct super_block *sb = inode->i_sb; | 329 | struct super_block *sb = inode->i_sb; |
330 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 330 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
331 | struct vfsmount *mnt = filp->f_path.mnt; | 331 | struct vfsmount *mnt = filp->f_path.mnt; |
332 | struct inode *dir = filp->f_path.dentry->d_parent->d_inode; | 332 | struct dentry *dir; |
333 | struct path path; | 333 | struct path path; |
334 | char buf[64], *cp; | 334 | char buf[64], *cp; |
335 | int ret; | 335 | int ret; |
@@ -373,14 +373,18 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
373 | if (ext4_encryption_info(inode) == NULL) | 373 | if (ext4_encryption_info(inode) == NULL) |
374 | return -ENOKEY; | 374 | return -ENOKEY; |
375 | } | 375 | } |
376 | if (ext4_encrypted_inode(dir) && | 376 | |
377 | !ext4_is_child_context_consistent_with_parent(dir, inode)) { | 377 | dir = dget_parent(file_dentry(filp)); |
378 | if (ext4_encrypted_inode(d_inode(dir)) && | ||
379 | !ext4_is_child_context_consistent_with_parent(d_inode(dir), inode)) { | ||
378 | ext4_warning(inode->i_sb, | 380 | ext4_warning(inode->i_sb, |
379 | "Inconsistent encryption contexts: %lu/%lu\n", | 381 | "Inconsistent encryption contexts: %lu/%lu\n", |
380 | (unsigned long) dir->i_ino, | 382 | (unsigned long) d_inode(dir)->i_ino, |
381 | (unsigned long) inode->i_ino); | 383 | (unsigned long) inode->i_ino); |
384 | dput(dir); | ||
382 | return -EPERM; | 385 | return -EPERM; |
383 | } | 386 | } |
387 | dput(dir); | ||
384 | /* | 388 | /* |
385 | * Set up the jbd2_inode if we are opening the inode for | 389 | * Set up the jbd2_inode if we are opening the inode for |
386 | * writing and the journal is present | 390 | * writing and the journal is present |
@@ -428,8 +432,8 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, | |||
428 | lastoff = startoff; | 432 | lastoff = startoff; |
429 | endoff = (loff_t)end_blk << blkbits; | 433 | endoff = (loff_t)end_blk << blkbits; |
430 | 434 | ||
431 | index = startoff >> PAGE_CACHE_SHIFT; | 435 | index = startoff >> PAGE_SHIFT; |
432 | end = endoff >> PAGE_CACHE_SHIFT; | 436 | end = endoff >> PAGE_SHIFT; |
433 | 437 | ||
434 | pagevec_init(&pvec, 0); | 438 | pagevec_init(&pvec, 0); |
435 | do { | 439 | do { |