Skip to content

Commit 0577d1b

Browse files
author
Al Viro
committed
cramfs: get_cramfs_inode() returns ERR_PTR() on failure
... and we want to report these failures in ->lookup() anyway. Signed-off-by: Al Viro <[email protected]>
1 parent 642c937 commit 0577d1b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

fs/cramfs/inode.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static DEFINE_MUTEX(read_mutex);
3737
/* These macros may change in future, to provide better st_ino semantics. */
3838
#define OFFSET(x) ((x)->i_ino)
3939

40-
static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
40+
static unsigned long cramino(const struct cramfs_inode *cino, unsigned int offset)
4141
{
4242
if (!cino->offset)
4343
return offset + 1;
@@ -61,7 +61,7 @@ static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
6161
}
6262

6363
static 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)
6565
{
6666
struct inode *inode;
6767
static struct timespec zerotime;
@@ -317,7 +317,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
317317
/* Set it all up.. */
318318
sb->s_op = &cramfs_ops;
319319
root = get_cramfs_inode(sb, &super.root, 0);
320-
if (!root)
320+
if (IS_ERR(root))
321321
goto out;
322322
sb->s_root = d_alloc_root(root);
323323
if (!sb->s_root) {
@@ -423,6 +423,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
423423
static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
424424
{
425425
unsigned int offset = 0;
426+
struct inode *inode = NULL;
426427
int sorted;
427428

428429
mutex_lock(&read_mutex);
@@ -449,8 +450,8 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
449450

450451
for (;;) {
451452
if (!namelen) {
452-
mutex_unlock(&read_mutex);
453-
return ERR_PTR(-EIO);
453+
inode = ERR_PTR(-EIO);
454+
goto out;
454455
}
455456
if (name[namelen-1])
456457
break;
@@ -462,17 +463,18 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
462463
if (retval > 0)
463464
continue;
464465
if (!retval) {
465-
struct cramfs_inode entry = *de;
466-
mutex_unlock(&read_mutex);
467-
d_add(dentry, get_cramfs_inode(dir->i_sb, &entry, dir_off));
468-
return NULL;
466+
inode = get_cramfs_inode(dir->i_sb, de, dir_off);
467+
break;
469468
}
470469
/* else (retval < 0) */
471470
if (sorted)
472471
break;
473472
}
473+
out:
474474
mutex_unlock(&read_mutex);
475-
d_add(dentry, NULL);
475+
if (IS_ERR(inode))
476+
return ERR_CAST(inode);
477+
d_add(dentry, inode);
476478
return NULL;
477479
}
478480

0 commit comments

Comments
 (0)