Skip to content

Commit acfa438

Browse files
author
Al Viro
committed
inode->i_op is never NULL
We used to have rather schizophrenic set of checks for NULL ->i_op even though it had been eliminated years ago. You'd need to go out of your way to set it to NULL explicitly _and_ a bunch of code would die on such inodes anyway. After killing two remaining places that still did that bogosity, all that crap can go away. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 9742df3 commit acfa438

10 files changed

Lines changed: 28 additions & 35 deletions

File tree

‎fs/cifs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset)
16411641
i_size_write(inode, offset);
16421642
spin_unlock(&inode->i_lock);
16431643
out_truncate:
1644-
if (inode->i_op && inode->i_op->truncate)
1644+
if (inode->i_op->truncate)
16451645
inode->i_op->truncate(inode);
16461646
return 0;
16471647
out_sig:

‎fs/ecryptfs/inode.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
612612
struct ecryptfs_crypt_stat *crypt_stat;
613613

614614
lower_dentry = ecryptfs_dentry_to_lower(dentry);
615-
if (!lower_dentry->d_inode->i_op ||
616-
!lower_dentry->d_inode->i_op->readlink) {
615+
if (!lower_dentry->d_inode->i_op->readlink) {
617616
rc = -EINVAL;
618617
goto out;
619618
}

‎fs/namei.c‎

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask)
257257
return -EACCES;
258258
}
259259

260-
if (inode->i_op && inode->i_op->permission)
260+
if (inode->i_op->permission)
261261
retval = inode->i_op->permission(inode, mask);
262262
else
263263
retval = generic_permission(inode, mask, NULL);
@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode)
432432
{
433433
umode_t mode = inode->i_mode;
434434

435-
if (inode->i_op && inode->i_op->permission)
435+
if (inode->i_op->permission)
436436
return -EAGAIN;
437437

438438
if (current_fsuid() == inode->i_uid)
@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
908908
inode = next.dentry->d_inode;
909909
if (!inode)
910910
goto out_dput;
911-
err = -ENOTDIR;
912-
if (!inode->i_op)
913-
goto out_dput;
914911

915912
if (inode->i_op->follow_link) {
916913
err = do_follow_link(&next, nd);
@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
920917
inode = nd->path.dentry->d_inode;
921918
if (!inode)
922919
break;
923-
err = -ENOTDIR;
924-
if (!inode->i_op)
925-
break;
926920
} else
927921
path_to_nameidata(&next, nd);
928922
err = -ENOTDIR;
@@ -961,7 +955,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
961955
break;
962956
inode = next.dentry->d_inode;
963957
if ((lookup_flags & LOOKUP_FOLLOW)
964-
&& inode && inode->i_op && inode->i_op->follow_link) {
958+
&& inode && inode->i_op->follow_link) {
965959
err = do_follow_link(&next, nd);
966960
if (err)
967961
goto return_err;
@@ -973,7 +967,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
973967
break;
974968
if (lookup_flags & LOOKUP_DIRECTORY) {
975969
err = -ENOTDIR;
976-
if (!inode->i_op || !inode->i_op->lookup)
970+
if (!inode->i_op->lookup)
977971
break;
978972
}
979973
goto return_base;
@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
14691463
if (error)
14701464
return error;
14711465

1472-
if (!dir->i_op || !dir->i_op->create)
1466+
if (!dir->i_op->create)
14731467
return -EACCES; /* shouldn't it be ENOSYS? */
14741468
mode &= S_IALLUGO;
14751469
mode |= S_IFREG;
@@ -1752,7 +1746,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
17521746
error = -ENOENT;
17531747
if (!path.dentry->d_inode)
17541748
goto exit_dput;
1755-
if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link)
1749+
if (path.dentry->d_inode->i_op->follow_link)
17561750
goto do_link;
17571751

17581752
path_to_nameidata(&path, &nd);
@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
19331927
if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
19341928
return -EPERM;
19351929

1936-
if (!dir->i_op || !dir->i_op->mknod)
1930+
if (!dir->i_op->mknod)
19371931
return -EPERM;
19381932

19391933
error = devcgroup_inode_mknod(mode, dev);
@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
20352029
if (error)
20362030
return error;
20372031

2038-
if (!dir->i_op || !dir->i_op->mkdir)
2032+
if (!dir->i_op->mkdir)
20392033
return -EPERM;
20402034

20412035
mode &= (S_IRWXUGO|S_ISVTX);
@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
21262120
if (error)
21272121
return error;
21282122

2129-
if (!dir->i_op || !dir->i_op->rmdir)
2123+
if (!dir->i_op->rmdir)
21302124
return -EPERM;
21312125

21322126
DQUOT_INIT(dir);
@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
22132207
if (error)
22142208
return error;
22152209

2216-
if (!dir->i_op || !dir->i_op->unlink)
2210+
if (!dir->i_op->unlink)
22172211
return -EPERM;
22182212

22192213
DQUOT_INIT(dir);
@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
23202314
if (error)
23212315
return error;
23222316

2323-
if (!dir->i_op || !dir->i_op->symlink)
2317+
if (!dir->i_op->symlink)
23242318
return -EPERM;
23252319

23262320
error = security_inode_symlink(dir, dentry, oldname);
@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
24012395
*/
24022396
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
24032397
return -EPERM;
2404-
if (!dir->i_op || !dir->i_op->link)
2398+
if (!dir->i_op->link)
24052399
return -EPERM;
24062400
if (S_ISDIR(inode->i_mode))
24072401
return -EPERM;
@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
26082602
if (error)
26092603
return error;
26102604

2611-
if (!old_dir->i_op || !old_dir->i_op->rename)
2605+
if (!old_dir->i_op->rename)
26122606
return -EPERM;
26132607

26142608
DQUOT_INIT(old_dir);

‎fs/nfsd/vfs.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
12111211
dirp = dentry->d_inode;
12121212

12131213
err = nfserr_notdir;
1214-
if(!dirp->i_op || !dirp->i_op->lookup)
1214+
if (!dirp->i_op->lookup)
12151215
goto out;
12161216
/*
12171217
* Check whether the response file handle has been verified yet.
@@ -1347,7 +1347,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
13471347
/* Get all the sanity checks out of the way before
13481348
* we lock the parent. */
13491349
err = nfserr_notdir;
1350-
if(!dirp->i_op || !dirp->i_op->lookup)
1350+
if (!dirp->i_op->lookup)
13511351
goto out;
13521352
fh_lock_nested(fhp, I_MUTEX_PARENT);
13531353

@@ -1482,7 +1482,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
14821482
inode = dentry->d_inode;
14831483

14841484
err = nfserr_inval;
1485-
if (!inode->i_op || !inode->i_op->readlink)
1485+
if (!inode->i_op->readlink)
14861486
goto out;
14871487

14881488
touch_atime(fhp->fh_export->ex_path.mnt, dentry);
@@ -2162,7 +2162,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
21622162
size_t size;
21632163
int error;
21642164

2165-
if (!IS_POSIXACL(inode) || !inode->i_op ||
2165+
if (!IS_POSIXACL(inode) ||
21662166
!inode->i_op->setxattr || !inode->i_op->removexattr)
21672167
return -EOPNOTSUPP;
21682168
switch(type) {

‎fs/open.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len)
412412
if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
413413
goto out_fput;
414414

415-
if (inode->i_op && inode->i_op->fallocate)
415+
if (inode->i_op->fallocate)
416416
ret = inode->i_op->fallocate(inode, mode, offset, len);
417417
else
418418
ret = -EOPNOTSUPP;

‎fs/stat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
305305
struct inode *inode = path.dentry->d_inode;
306306

307307
error = -EINVAL;
308-
if (inode->i_op && inode->i_op->readlink) {
308+
if (inode->i_op->readlink) {
309309
error = security_inode_readlink(path.dentry);
310310
if (!error) {
311311
touch_atime(path.mnt, path.dentry);

‎fs/xattr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size)
175175
if (error)
176176
return error;
177177
error = -EOPNOTSUPP;
178-
if (d->d_inode->i_op && d->d_inode->i_op->listxattr) {
178+
if (d->d_inode->i_op->listxattr) {
179179
error = d->d_inode->i_op->listxattr(d, list, size);
180180
} else {
181181
error = security_inode_listsecurity(d->d_inode, list, size);

‎mm/memory.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset)
22662266
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
22672267
}
22682268

2269-
if (inode->i_op && inode->i_op->truncate)
2269+
if (inode->i_op->truncate)
22702270
inode->i_op->truncate(inode);
22712271
return 0;
22722272

@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
22862286
* a way to truncate a range of blocks (punch a hole) -
22872287
* we should return failure right now.
22882288
*/
2289-
if (!inode->i_op || !inode->i_op->truncate_range)
2289+
if (!inode->i_op->truncate_range)
22902290
return -ENOSYS;
22912291

22922292
mutex_lock(&inode->i_mutex);

‎mm/nommu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int vmtruncate(struct inode *inode, loff_t offset)
8686
i_size_write(inode, offset);
8787

8888
out_truncate:
89-
if (inode->i_op && inode->i_op->truncate)
89+
if (inode->i_op->truncate)
9090
inode->i_op->truncate(inode);
9191
return 0;
9292
out_sig:

‎security/commoncap.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
238238
struct inode *inode = dentry->d_inode;
239239
int error;
240240

241-
if (!inode->i_op || !inode->i_op->getxattr)
241+
if (!inode->i_op->getxattr)
242242
return 0;
243243

244244
error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry)
259259
{
260260
struct inode *inode = dentry->d_inode;
261261

262-
if (!inode->i_op || !inode->i_op->removexattr)
262+
if (!inode->i_op->removexattr)
263263
return 0;
264264

265265
return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS);
@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
317317

318318
memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
319319

320-
if (!inode || !inode->i_op || !inode->i_op->getxattr)
320+
if (!inode || !inode->i_op->getxattr)
321321
return -ENODATA;
322322

323323
size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps,

0 commit comments

Comments
 (0)