fs: check f_op before dereference its field
PATCH 1/1 fs: check f_op before dereference its field
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 <[email protected]>
--- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/open.c +1 -1
@@ -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);
Signature · 1 line
1.7.9.5
Al Viro
maintainerQuoted 3 lines · Jiang Fang
I don't know whether we can have NULL
f_optoday, but a quick grep of '!file->f_op->' in fs directory shows most of times we do the check. So fix the missing one.
We should remove the bogus ones, actually, and hunt down the remaining few places that set ->f_op to NULL (AFAICS, all of them in dvb and in ->release() instances, at that; note that no methods can be ever called after ->release(), so these assignments are pointless _and_ irrelevant for any call sites of the methods).