From: Luis Henriques Date: Wed, 11 Jul 2012 21:02:10 +0000 (-0700) Subject: ocfs2: fix NULL pointer dereference in __ocfs2_change_file_space() X-Git-Tag: v2.6.39-400.9.0~339^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=02f34ff63e93aca62b6b8b830ef1c0048485110b;p=users%2Fjedix%2Flinux-maple.git ocfs2: fix NULL pointer dereference in __ocfs2_change_file_space() As ocfs2_fallocate() will invoke __ocfs2_change_file_space() with a NULL as the first parameter (file), it may trigger a NULL pointer dereferrence due to a missing check. Addresses http://bugs.launchpad.net/bugs/1006012 Signed-off-by: Luis Henriques Reported-by: Bret Towe Tested-by: Bret Towe Cc: Sunil Mushran Acked-by: Joel Becker Acked-by: Mark Fasheh Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit a4e08d001f2e50bb8b3c4eebadcf08e5535f02ee) Signed-off-by: Xiaowei.Hu --- diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index a666d62a537b..1dcd1580ccd7 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -1936,7 +1936,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);