Skip to content

Commit 542532a

Browse files
aalexandrovichgregkh
authored andcommitted
fs/ntfs3: Additional check in ntfs_file_release
commit 031d6f6 upstream. Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]> Signed-off-by: Bin Lan <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Suraj Jitindar Singh <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 00767fb commit 542532a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/ntfs3/file.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,16 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
11921192
int err = 0;
11931193

11941194
/* If we are last writer on the inode, drop the block reservation. */
1195-
if (sbi->options->prealloc && ((file->f_mode & FMODE_WRITE) &&
1196-
atomic_read(&inode->i_writecount) == 1)) {
1195+
if (sbi->options->prealloc &&
1196+
((file->f_mode & FMODE_WRITE) &&
1197+
atomic_read(&inode->i_writecount) == 1)
1198+
/*
1199+
* The only file when inode->i_fop = &ntfs_file_operations and
1200+
* init_rwsem(&ni->file.run_lock) is not called explicitly is MFT.
1201+
*
1202+
* Add additional check here.
1203+
*/
1204+
&& inode->i_ino != MFT_REC_MFT) {
11971205
ni_lock(ni);
11981206
down_write(&ni->file.run_lock);
11991207

0 commit comments

Comments
 (0)