[PATCH 10/18] orangefs: BUG_ON if i_mode invalid

From: Martin Brandenburg
Date: Tue Dec 12 2017 - 13:37:46 EST


From: Martin Brandenburg <martin@xxxxxxxxxxxx>

This can't happen since it would have been caught (and a graceful
error returned) earlier.

Signed-off-by: Martin Brandenburg <martin@xxxxxxxxxxxx>
---
fs/orangefs/inode.c | 14 ++++----------
fs/orangefs/orangefs-utils.c | 4 ++++
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index cf6924c36a22..f3a157571a6a 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -193,22 +193,16 @@ static int orangefs_init_iops(struct inode *inode)
inode->i_fop = &orangefs_file_operations;
inode->i_data.a_ops = &orangefs_address_operations;
inode->i_blkbits = PAGE_SHIFT;
- break;
+ return 0;
case S_IFLNK:
inode->i_op = &orangefs_symlink_inode_operations;
- break;
+ return 0;
case S_IFDIR:
inode->i_op = &orangefs_dir_inode_operations;
inode->i_fop = &orangefs_dir_operations;
- break;
- default:
- gossip_debug(GOSSIP_INODE_DEBUG,
- "%s: unsupported mode\n",
- __func__);
- return -EINVAL;
+ return 0;
}
-
- return 0;
+ BUG_ON(1);
}

/*
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 553b3ded51cd..2c5b7a3d7793 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -296,6 +296,10 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,

type = orangefs_inode_type(new_op->
downcall.resp.getattr.attributes.objtype);
+ if (type == -1) {
+ ret = -EIO;
+ goto out;
+ }
ret = orangefs_inode_is_stale(inode, new,
&new_op->downcall.resp.getattr.attributes,
new_op->downcall.resp.getattr.link_target);
--
2.15.1