Skip to content

Commit 583fee3

Browse files
XidianGeneraltorvalds
authored andcommitted
fs: ocfs2: fix a possible null-pointer dereference in ocfs2_write_end_nolock()
In ocfs2_write_end_nolock(), there are an if statement on lines 1976, 2047 and 2058, to check whether handle is NULL: if (handle) When handle is NULL, it is used on line 2045: ocfs2_update_inode_fsync_trans(handle, inode, 1); oi->i_sync_tid = handle->h_transaction->t_tid; Thus, a possible null-pointer dereference may occur. To fix this bug, handle is checked before calling ocfs2_update_inode_fsync_trans(). This bug is found by a static analysis tool STCheck written by us. Link: http://lkml.kernel.org/r/20190726033705.32307-1-baijiaju1990@gmail.com Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 56e94ea commit 583fee3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/ocfs2/aops.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
20492049
inode->i_mtime = inode->i_ctime = current_time(inode);
20502050
di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
20512051
di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
2052-
ocfs2_update_inode_fsync_trans(handle, inode, 1);
2052+
if (handle)
2053+
ocfs2_update_inode_fsync_trans(handle, inode, 1);
20532054
}
20542055
if (handle)
20552056
ocfs2_journal_dirty(handle, wc->w_di_bh);

0 commit comments

Comments
 (0)