aboutsummaryrefslogtreecommitdiffstats
path: root/fs/adfs
diff options
context:
space:
mode:
authorSanidhya Kashyap <sanidhya.gatech@gmail.com>2015-04-16 15:48:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 09:04:08 -0400
commitb796410630a0f090864d7595c6bffbc0136f0f8c (patch)
tree1888b4a7745f67896ccf0da3a95cff69c69d3336 /fs/adfs
parent9d796e66230205cd3366f5660387bd9ecca9d336 (diff)
adfs: return correct return values
Fix the wrong values returned by various functions such as EIO and ENOMEM. Signed-off-by: Sanidhya 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/adfs')
-rw-r--r--fs/adfs/dir_fplus.c1
-rw-r--r--fs/adfs/super.c20
2 files changed, 16 insertions, 5 deletions
diff --git a/fs/adfs/dir_fplus.c b/fs/adfs/dir_fplus.c
index f2ba88ab4aed..82d14cdf70f9 100644
--- a/fs/adfs/dir_fplus.c
+++ b/fs/adfs/dir_fplus.c
@@ -61,6 +61,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
61 kcalloc(size, sizeof(struct buffer_head *), 61 kcalloc(size, sizeof(struct buffer_head *),
62 GFP_KERNEL); 62 GFP_KERNEL);
63 if (!bh_fplus) { 63 if (!bh_fplus) {
64 ret = -ENOMEM;
64 adfs_error(sb, "not enough memory for" 65 adfs_error(sb, "not enough memory for"
65 " dir object %X (%d blocks)", id, size); 66 " dir object %X (%d blocks)", id, size);
66 goto out; 67 goto out;
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 9852bdf34d76..a19c31d3f369 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -316,7 +316,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
316 dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL); 316 dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL);
317 if (dm == NULL) { 317 if (dm == NULL) {
318 adfs_error(sb, "not enough memory"); 318 adfs_error(sb, "not enough memory");
319 return NULL; 319 return ERR_PTR(-ENOMEM);
320 } 320 }
321 321
322 for (zone = 0; zone < nzones; zone++, map_addr++) { 322 for (zone = 0; zone < nzones; zone++, map_addr++) {
@@ -349,7 +349,7 @@ error_free:
349 brelse(dm[zone].dm_bh); 349 brelse(dm[zone].dm_bh);
350 350
351 kfree(dm); 351 kfree(dm);
352 return NULL; 352 return ERR_PTR(-EIO);
353} 353}
354 354
355static inline unsigned long adfs_discsize(struct adfs_discrecord *dr, int block_bits) 355static 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 unsigned char *b_data; 370 unsigned char *b_data;
371 struct adfs_sb_info *asb; 371 struct adfs_sb_info *asb;
372 struct inode *root; 372 struct inode *root;
373 int ret = -EINVAL;
373 374
374 sb->s_flags |= MS_NODIRATIME; 375 sb->s_flags |= MS_NODIRATIME;
375 376
@@ -391,6 +392,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
391 sb_set_blocksize(sb, BLOCK_SIZE); 392 sb_set_blocksize(sb, BLOCK_SIZE);
392 if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) { 393 if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) {
393 adfs_error(sb, "unable to read superblock"); 394 adfs_error(sb, "unable to read superblock");
395 ret = -EIO;
394 goto error; 396 goto error;
395 } 397 }
396 398
@@ -400,6 +402,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
400 if (!silent) 402 if (!silent)
401 printk("VFS: Can't find an adfs filesystem on dev " 403 printk("VFS: Can't find an adfs filesystem on dev "
402 "%s.\n", sb->s_id); 404 "%s.\n", sb->s_id);
405 ret = -EINVAL;
403 goto error_free_bh; 406 goto error_free_bh;
404 } 407 }
405 408
@@ -412,6 +415,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
412 if (!silent) 415 if (!silent)
413 printk("VPS: Can't find an adfs filesystem on dev " 416 printk("VPS: Can't find an adfs filesystem on dev "
414 "%s.\n", sb->s_id); 417 "%s.\n", sb->s_id);
418 ret = -EINVAL;
415 goto error_free_bh; 419 goto error_free_bh;
416 } 420 }
417 421
@@ -421,11 +425,13 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
421 if (!bh) { 425 if (!bh) {
422 adfs_error(sb, "couldn't read superblock on " 426 adfs_error(sb, "couldn't read superblock on "
423 "2nd try."); 427 "2nd try.");
428 ret = -EIO;
424 goto error; 429 goto error;
425 } 430 }
426 b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize); 431 b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize);
427 if (adfs_checkbblk(b_data)) { 432 if (adfs_checkbblk(b_data)) {
428 adfs_error(sb, "disc record mismatch, very weird!"); 433 adfs_error(sb, "disc record mismatch, very weird!");
434 ret = -EINVAL;
429 goto error_free_bh; 435 goto error_free_bh;
430 } 436 }
431 dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET); 437 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 if (!silent) 439 if (!silent)
434 printk(KERN_ERR "VFS: Unsupported blocksize on dev " 440 printk(KERN_ERR "VFS: Unsupported blocksize on dev "
435 "%s.\n", sb->s_id); 441 "%s.\n", sb->s_id);
442 ret = -EINVAL;
436 goto error; 443 goto error;
437 } 444 }
438 445
@@ -447,10 +454,12 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
447 asb->s_size = adfs_discsize(dr, sb->s_blocksize_bits); 454 asb->s_size = adfs_discsize(dr, sb->s_blocksize_bits);
448 asb->s_version = dr->format_version; 455 asb->s_version = dr->format_version;
449 asb->s_log2sharesize = dr->log2sharesize; 456 asb->s_log2sharesize = dr->log2sharesize;
450 457
451 asb->s_map = adfs_read_map(sb, dr); 458 asb->s_map = adfs_read_map(sb, dr);
452 if (!asb->s_map) 459 if (IS_ERR(asb->s_map)) {
460 ret = PTR_ERR(asb->s_map);
453 goto error_free_bh; 461 goto error_free_bh;
462 }
454 463
455 brelse(bh); 464 brelse(bh);
456 465
@@ -499,6 +508,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
499 brelse(asb->s_map[i].dm_bh); 508 brelse(asb->s_map[i].dm_bh);
500 kfree(asb->s_map); 509 kfree(asb->s_map);
501 adfs_error(sb, "get root inode failed\n"); 510 adfs_error(sb, "get root inode failed\n");
511 ret = -EIO;
502 goto error; 512 goto error;
503 } 513 }
504 return 0; 514 return 0;
@@ -508,7 +518,7 @@ error_free_bh:
508error: 518error:
509 sb->s_fs_info = NULL; 519 sb->s_fs_info = NULL;
510 kfree(asb); 520 kfree(asb);
511 return -EINVAL; 521 return ret;
512} 522}
513 523
514static struct dentry *adfs_mount(struct file_system_type *fs_type, 524static struct dentry *adfs_mount(struct file_system_type *fs_type,