aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-07-17 19:04:14 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-17 23:22:02 -0400
commit0577d1ba411f9c40693b8b3e4aa7e0892cd03091 (patch)
tree1da66779d615071aaa00b12530569e057b0845db
parent642c937b4ed2e51d2f2e4c46ab7cd8b5bddf268b (diff)
cramfs: get_cramfs_inode() returns ERR_PTR() on failure
... and we want to report these failures in ->lookup() anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/cramfs/inode.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index e141939080f0..739fb59bcdc2 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -37,7 +37,7 @@ static DEFINE_MUTEX(read_mutex);
37/* These macros may change in future, to provide better st_ino semantics. */ 37/* These macros may change in future, to provide better st_ino semantics. */
38#define OFFSET(x) ((x)->i_ino) 38#define OFFSET(x) ((x)->i_ino)
39 39
40static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset) 40static unsigned long cramino(const struct cramfs_inode *cino, unsigned int offset)
41{ 41{
42 if (!cino->offset) 42 if (!cino->offset)
43 return offset + 1; 43 return offset + 1;
@@ -61,7 +61,7 @@ static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
61} 61}
62 62
63static struct inode *get_cramfs_inode(struct super_block *sb, 63static struct inode *get_cramfs_inode(struct super_block *sb,
64 struct cramfs_inode *cramfs_inode, unsigned int offset) 64 const struct cramfs_inode *cramfs_inode, unsigned int offset)
65{ 65{
66 struct inode *inode; 66 struct inode *inode;
67 static struct timespec zerotime; 67 static struct timespec zerotime;
@@ -317,7 +317,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
317 /* Set it all up.. */ 317 /* Set it all up.. */
318 sb->s_op = &cramfs_ops; 318 sb->s_op = &cramfs_ops;
319 root = get_cramfs_inode(sb, &super.root, 0); 319 root = get_cramfs_inode(sb, &super.root, 0);
320 if (!root) 320 if (IS_ERR(root))
321 goto out; 321 goto out;
322 sb->s_root = d_alloc_root(root); 322 sb->s_root = d_alloc_root(root);
323 if (!sb->s_root) { 323 if (!sb->s_root) {
@@ -423,6 +423,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
423static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 423static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
424{ 424{
425 unsigned int offset = 0; 425 unsigned int offset = 0;
426 struct inode *inode = NULL;
426 int sorted; 427 int sorted;
427 428
428 mutex_lock(&read_mutex); 429 mutex_lock(&read_mutex);
@@ -449,8 +450,8 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
449 450
450 for (;;) { 451 for (;;) {
451 if (!namelen) { 452 if (!namelen) {
452 mutex_unlock(&read_mutex); 453 inode = ERR_PTR(-EIO);
453 return ERR_PTR(-EIO); 454 goto out;
454 } 455 }
455 if (name[namelen-1]) 456 if (name[namelen-1])
456 break; 457 break;
@@ -462,17 +463,18 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
462 if (retval > 0) 463 if (retval > 0)
463 continue; 464 continue;
464 if (!retval) { 465 if (!retval) {
465 struct cramfs_inode entry = *de; 466 inode = get_cramfs_inode(dir->i_sb, de, dir_off);
466 mutex_unlock(&read_mutex); 467 break;
467 d_add(dentry, get_cramfs_inode(dir->i_sb, &entry, dir_off));
468 return NULL;
469 } 468 }
470 /* else (retval < 0) */ 469 /* else (retval < 0) */
471 if (sorted) 470 if (sorted)
472 break; 471 break;
473 } 472 }
473out:
474 mutex_unlock(&read_mutex); 474 mutex_unlock(&read_mutex);
475 d_add(dentry, NULL); 475 if (IS_ERR(inode))
476 return ERR_CAST(inode);
477 d_add(dentry, inode);
476 return NULL; 478 return NULL;
477} 479}
478 480