diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 98513c8ed589f775f94c91259fa87ea5d364f2d0..7602783d7f41c9a01827f16446da43e036e6a7cb 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1950,7 +1950,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
 	if (ret < 0)
 		mlog_errno(ret);
 
-	if (file->f_flags & O_SYNC)
+	if (file && (file->f_flags & O_SYNC))
 		handle->h_sync = 1;
 
 	ocfs2_commit_trans(osb, handle);