linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiang Fang <jiang.xx.fang@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] fs: check f_op before dereference its field
Date: Thu, 24 Jan 2013 22:53:20 +0800	[thread overview]
Message-ID: <1359039200-6232-1-git-send-email-jiang.xx.fang@gmail.com> (raw)

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 <jiang.xx.fang@gmail.com>
---
 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


             reply	other threads:[~2013-01-24 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24 14:53 Jiang Fang [this message]
2013-01-24 15:28 ` [PATCH] fs: check f_op before dereference its field Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359039200-6232-1-git-send-email-jiang.xx.fang@gmail.com \
    --to=jiang.xx.fang@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).