Commit b7964106 authored by Sanidhya Kashyap's avatar Sanidhya Kashyap Committed by Linus Torvalds

adfs: return correct return values

Fix the wrong values returned by various functions such as EIO and ENOMEM.
Signed-off-by: default avatarSanidhya Kashyap <sanidhya.gatech@gmail.com>
Cc: Fabian Frederick <fabf@skynet.be>
Cc: Joe Perches <joe@perches.com>
Cc: Taesoo kim <taesoo@gatech.edu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9d796e66
...@@ -61,6 +61,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -61,6 +61,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
kcalloc(size, sizeof(struct buffer_head *), kcalloc(size, sizeof(struct buffer_head *),
GFP_KERNEL); GFP_KERNEL);
if (!bh_fplus) { if (!bh_fplus) {
ret = -ENOMEM;
adfs_error(sb, "not enough memory for" adfs_error(sb, "not enough memory for"
" dir object %X (%d blocks)", id, size); " dir object %X (%d blocks)", id, size);
goto out; goto out;
......
...@@ -316,7 +316,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di ...@@ -316,7 +316,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL); dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL);
if (dm == NULL) { if (dm == NULL) {
adfs_error(sb, "not enough memory"); adfs_error(sb, "not enough memory");
return NULL; return ERR_PTR(-ENOMEM);
} }
for (zone = 0; zone < nzones; zone++, map_addr++) { for (zone = 0; zone < nzones; zone++, map_addr++) {
...@@ -349,7 +349,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di ...@@ -349,7 +349,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
brelse(dm[zone].dm_bh); brelse(dm[zone].dm_bh);
kfree(dm); kfree(dm);
return NULL; return ERR_PTR(-EIO);
} }
static inline unsigned long adfs_discsize(struct adfs_discrecord *dr, int block_bits) static inline unsigned long adfs_discsize(struct adfs_discrecord *dr, int block_bits)
...@@ -370,6 +370,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -370,6 +370,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
unsigned char *b_data; unsigned char *b_data;
struct adfs_sb_info *asb; struct adfs_sb_info *asb;
struct inode *root; struct inode *root;
int ret = -EINVAL;
sb->s_flags |= MS_NODIRATIME; sb->s_flags |= MS_NODIRATIME;
...@@ -391,6 +392,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -391,6 +392,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
sb_set_blocksize(sb, BLOCK_SIZE); sb_set_blocksize(sb, BLOCK_SIZE);
if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) { if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) {
adfs_error(sb, "unable to read superblock"); adfs_error(sb, "unable to read superblock");
ret = -EIO;
goto error; goto error;
} }
...@@ -400,6 +402,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -400,6 +402,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
if (!silent) if (!silent)
printk("VFS: Can't find an adfs filesystem on dev " printk("VFS: Can't find an adfs filesystem on dev "
"%s.\n", sb->s_id); "%s.\n", sb->s_id);
ret = -EINVAL;
goto error_free_bh; goto error_free_bh;
} }
...@@ -412,6 +415,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -412,6 +415,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
if (!silent) if (!silent)
printk("VPS: Can't find an adfs filesystem on dev " printk("VPS: Can't find an adfs filesystem on dev "
"%s.\n", sb->s_id); "%s.\n", sb->s_id);
ret = -EINVAL;
goto error_free_bh; goto error_free_bh;
} }
...@@ -421,11 +425,13 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -421,11 +425,13 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
if (!bh) { if (!bh) {
adfs_error(sb, "couldn't read superblock on " adfs_error(sb, "couldn't read superblock on "
"2nd try."); "2nd try.");
ret = -EIO;
goto error; goto error;
} }
b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize); b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize);
if (adfs_checkbblk(b_data)) { if (adfs_checkbblk(b_data)) {
adfs_error(sb, "disc record mismatch, very weird!"); adfs_error(sb, "disc record mismatch, very weird!");
ret = -EINVAL;
goto error_free_bh; goto error_free_bh;
} }
dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET); dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
...@@ -433,6 +439,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -433,6 +439,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
if (!silent) if (!silent)
printk(KERN_ERR "VFS: Unsupported blocksize on dev " printk(KERN_ERR "VFS: Unsupported blocksize on dev "
"%s.\n", sb->s_id); "%s.\n", sb->s_id);
ret = -EINVAL;
goto error; goto error;
} }
...@@ -447,10 +454,12 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -447,10 +454,12 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
asb->s_size = adfs_discsize(dr, sb->s_blocksize_bits); asb->s_size = adfs_discsize(dr, sb->s_blocksize_bits);
asb->s_version = dr->format_version; asb->s_version = dr->format_version;
asb->s_log2sharesize = dr->log2sharesize; asb->s_log2sharesize = dr->log2sharesize;
asb->s_map = adfs_read_map(sb, dr); asb->s_map = adfs_read_map(sb, dr);
if (!asb->s_map) if (IS_ERR(asb->s_map)) {
ret = PTR_ERR(asb->s_map);
goto error_free_bh; goto error_free_bh;
}
brelse(bh); brelse(bh);
...@@ -499,6 +508,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -499,6 +508,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
brelse(asb->s_map[i].dm_bh); brelse(asb->s_map[i].dm_bh);
kfree(asb->s_map); kfree(asb->s_map);
adfs_error(sb, "get root inode failed\n"); adfs_error(sb, "get root inode failed\n");
ret = -EIO;
goto error; goto error;
} }
return 0; return 0;
...@@ -508,7 +518,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -508,7 +518,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
error: error:
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
kfree(asb); kfree(asb);
return -EINVAL; return ret;
} }
static struct dentry *adfs_mount(struct file_system_type *fs_type, static struct dentry *adfs_mount(struct file_system_type *fs_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment