From: Jiang Fang Subject: [PATCH] fs: check f_op before dereference its field Date: Thu, 24 Jan 2013 22:53:20 +0800 Message-ID: <1359039200-6232-1-git-send-email-jiang.xx.fang@gmail.com> Cc: linux-fsdevel@vger.kernel.org To: viro@zeniv.linux.org.uk Return-path: Received: from mail-da0-f43.google.com ([209.85.210.43]:35725 "EHLO mail-da0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753890Ab3AXOyS (ORCPT ); Thu, 24 Jan 2013 09:54:18 -0500 Received: by mail-da0-f43.google.com with SMTP id u36so4310948dak.30 for ; Thu, 24 Jan 2013 06:54:18 -0800 (PST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: I don't know whether we can have NULL f_op today, but a quick grep of '!file->f_op->' in fs directory shows most of times we do the check. So fix the missing one. Signed-off-by: Jiang Fang --- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index 9b33c0c..192dd86 100644 --- a/fs/open.c +++ b/fs/open.c @@ -275,7 +275,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) return -EFBIG; - if (!file->f_op->fallocate) + if (!file->f_op || !file->f_op->fallocate) return -EOPNOTSUPP; sb_start_write(inode->i_sb); -- 1.7.9.5