@@ -54,7 +54,7 @@ static void isofs_put_super(struct super_block *sb)
54
54
return ;
55
55
}
56
56
57
- static void isofs_read_inode (struct inode * );
57
+ static int isofs_read_inode (struct inode * );
58
58
static int isofs_statfs (struct dentry * , struct kstatfs * );
59
59
60
60
static struct kmem_cache * isofs_inode_cachep ;
@@ -107,7 +107,6 @@ static int isofs_remount(struct super_block *sb, int *flags, char *data)
107
107
static const struct super_operations isofs_sops = {
108
108
.alloc_inode = isofs_alloc_inode ,
109
109
.destroy_inode = isofs_destroy_inode ,
110
- .read_inode = isofs_read_inode ,
111
110
.put_super = isofs_put_super ,
112
111
.statfs = isofs_statfs ,
113
112
.remount_fs = isofs_remount ,
@@ -552,7 +551,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
552
551
int joliet_level = 0 ;
553
552
int iso_blknum , block ;
554
553
int orig_zonesize ;
555
- int table ;
554
+ int table , error = - EINVAL ;
556
555
unsigned int vol_desc_start ;
557
556
558
557
sbi = kzalloc (sizeof (* sbi ), GFP_KERNEL );
@@ -810,6 +809,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
810
809
* we then decide whether to use the Joliet descriptor.
811
810
*/
812
811
inode = isofs_iget (s , sbi -> s_firstdatazone , 0 );
812
+ if (IS_ERR (inode ))
813
+ goto out_no_root ;
813
814
814
815
/*
815
816
* If this disk has both Rock Ridge and Joliet on it, then we
@@ -829,6 +830,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
829
830
"ISOFS: changing to secondary root\n" );
830
831
iput (inode );
831
832
inode = isofs_iget (s , sbi -> s_firstdatazone , 0 );
833
+ if (IS_ERR (inode ))
834
+ goto out_no_root ;
832
835
}
833
836
}
834
837
@@ -842,8 +845,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
842
845
sbi -> s_joliet_level = joliet_level ;
843
846
844
847
/* check the root inode */
845
- if (!inode )
846
- goto out_no_root ;
847
848
if (!inode -> i_op )
848
849
goto out_bad_root ;
849
850
@@ -876,11 +877,14 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
876
877
*/
877
878
out_bad_root :
878
879
printk (KERN_WARNING "%s: root inode not initialized\n" , __func__ );
879
- goto out_iput ;
880
- out_no_root :
881
- printk (KERN_WARNING "%s: get root inode failed\n" , __func__ );
882
880
out_iput :
883
881
iput (inode );
882
+ goto out_no_inode ;
883
+ out_no_root :
884
+ error = PTR_ERR (inode );
885
+ if (error != - ENOMEM )
886
+ printk (KERN_WARNING "%s: get root inode failed\n" , __func__ );
887
+ out_no_inode :
884
888
#ifdef CONFIG_JOLIET
885
889
if (sbi -> s_nls_iocharset )
886
890
unload_nls (sbi -> s_nls_iocharset );
@@ -908,7 +912,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
908
912
kfree (opt .iocharset );
909
913
kfree (sbi );
910
914
s -> s_fs_info = NULL ;
911
- return - EINVAL ;
915
+ return error ;
912
916
}
913
917
914
918
static int isofs_statfs (struct dentry * dentry , struct kstatfs * buf )
@@ -930,7 +934,7 @@ static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf)
930
934
/*
931
935
* Get a set of blocks; filling in buffer_heads if already allocated
932
936
* or getblk() if they are not. Returns the number of blocks inserted
933
- * (0 == error.)
937
+ * (-ve == error.)
934
938
*/
935
939
int isofs_get_blocks (struct inode * inode , sector_t iblock_s ,
936
940
struct buffer_head * * bh , unsigned long nblocks )
@@ -940,11 +944,12 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
940
944
unsigned int firstext ;
941
945
unsigned long nextblk , nextoff ;
942
946
long iblock = (long )iblock_s ;
943
- int section , rv ;
947
+ int section , rv , error ;
944
948
struct iso_inode_info * ei = ISOFS_I (inode );
945
949
946
950
lock_kernel ();
947
951
952
+ error = - EIO ;
948
953
rv = 0 ;
949
954
if (iblock < 0 || iblock != iblock_s ) {
950
955
printk (KERN_DEBUG "%s: block number too large\n" , __func__ );
@@ -983,8 +988,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
983
988
984
989
offset += sect_size ;
985
990
ninode = isofs_iget (inode -> i_sb , nextblk , nextoff );
986
- if (!ninode )
991
+ if (IS_ERR (ninode )) {
992
+ error = PTR_ERR (ninode );
987
993
goto abort ;
994
+ }
988
995
firstext = ISOFS_I (ninode )-> i_first_extent ;
989
996
sect_size = ISOFS_I (ninode )-> i_section_size >> ISOFS_BUFFER_BITS (ninode );
990
997
nextblk = ISOFS_I (ninode )-> i_next_section_block ;
@@ -1015,9 +1022,10 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1015
1022
rv ++ ;
1016
1023
}
1017
1024
1025
+ error = 0 ;
1018
1026
abort :
1019
1027
unlock_kernel ();
1020
- return rv ;
1028
+ return rv != 0 ? rv : error ;
1021
1029
}
1022
1030
1023
1031
/*
@@ -1026,12 +1034,15 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1026
1034
static int isofs_get_block (struct inode * inode , sector_t iblock ,
1027
1035
struct buffer_head * bh_result , int create )
1028
1036
{
1037
+ int ret ;
1038
+
1029
1039
if (create ) {
1030
1040
printk (KERN_DEBUG "%s: Kernel tries to allocate a block\n" , __func__ );
1031
1041
return - EROFS ;
1032
1042
}
1033
1043
1034
- return isofs_get_blocks (inode , iblock , & bh_result , 1 ) ? 0 : - EIO ;
1044
+ ret = isofs_get_blocks (inode , iblock , & bh_result , 1 );
1045
+ return ret < 0 ? ret : 0 ;
1035
1046
}
1036
1047
1037
1048
static int isofs_bmap (struct inode * inode , sector_t block )
@@ -1186,7 +1197,7 @@ static int isofs_read_level3_size(struct inode *inode)
1186
1197
goto out ;
1187
1198
}
1188
1199
1189
- static void isofs_read_inode (struct inode * inode )
1200
+ static int isofs_read_inode (struct inode * inode )
1190
1201
{
1191
1202
struct super_block * sb = inode -> i_sb ;
1192
1203
struct isofs_sb_info * sbi = ISOFS_SB (sb );
@@ -1199,6 +1210,7 @@ static void isofs_read_inode(struct inode *inode)
1199
1210
unsigned int de_len ;
1200
1211
unsigned long offset ;
1201
1212
struct iso_inode_info * ei = ISOFS_I (inode );
1213
+ int ret = - EIO ;
1202
1214
1203
1215
block = ei -> i_iget5_block ;
1204
1216
bh = sb_bread (inode -> i_sb , block );
@@ -1216,6 +1228,7 @@ static void isofs_read_inode(struct inode *inode)
1216
1228
tmpde = kmalloc (de_len , GFP_KERNEL );
1217
1229
if (tmpde == NULL ) {
1218
1230
printk (KERN_INFO "%s: out of memory\n" , __func__ );
1231
+ ret = - ENOMEM ;
1219
1232
goto fail ;
1220
1233
}
1221
1234
memcpy (tmpde , bh -> b_data + offset , frag1 );
@@ -1259,8 +1272,10 @@ static void isofs_read_inode(struct inode *inode)
1259
1272
1260
1273
ei -> i_section_size = isonum_733 (de -> size );
1261
1274
if (de -> flags [- high_sierra ] & 0x80 ) {
1262
- if (isofs_read_level3_size (inode ))
1275
+ ret = isofs_read_level3_size (inode );
1276
+ if (ret < 0 )
1263
1277
goto fail ;
1278
+ ret = - EIO ;
1264
1279
} else {
1265
1280
ei -> i_next_section_block = 0 ;
1266
1281
ei -> i_next_section_offset = 0 ;
@@ -1346,16 +1361,16 @@ static void isofs_read_inode(struct inode *inode)
1346
1361
/* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1347
1362
init_special_inode (inode , inode -> i_mode , inode -> i_rdev );
1348
1363
1364
+ ret = 0 ;
1349
1365
out :
1350
1366
kfree (tmpde );
1351
1367
if (bh )
1352
1368
brelse (bh );
1353
- return ;
1369
+ return ret ;
1354
1370
1355
1371
out_badread :
1356
1372
printk (KERN_WARNING "ISOFS: unable to read i-node block\n" );
1357
1373
fail :
1358
- make_bad_inode (inode );
1359
1374
goto out ;
1360
1375
}
1361
1376
@@ -1394,9 +1409,10 @@ struct inode *isofs_iget(struct super_block *sb,
1394
1409
unsigned long hashval ;
1395
1410
struct inode * inode ;
1396
1411
struct isofs_iget5_callback_data data ;
1412
+ long ret ;
1397
1413
1398
1414
if (offset >= 1ul << sb -> s_blocksize_bits )
1399
- return NULL ;
1415
+ return ERR_PTR ( - EINVAL ) ;
1400
1416
1401
1417
data .block = block ;
1402
1418
data .offset = offset ;
@@ -1406,9 +1422,17 @@ struct inode *isofs_iget(struct super_block *sb,
1406
1422
inode = iget5_locked (sb , hashval , & isofs_iget5_test ,
1407
1423
& isofs_iget5_set , & data );
1408
1424
1409
- if (inode && (inode -> i_state & I_NEW )) {
1410
- sb -> s_op -> read_inode (inode );
1411
- unlock_new_inode (inode );
1425
+ if (!inode )
1426
+ return ERR_PTR (- ENOMEM );
1427
+
1428
+ if (inode -> i_state & I_NEW ) {
1429
+ ret = isofs_read_inode (inode );
1430
+ if (ret < 0 ) {
1431
+ iget_failed (inode );
1432
+ inode = ERR_PTR (ret );
1433
+ } else {
1434
+ unlock_new_inode (inode );
1435
+ }
1412
1436
}
1413
1437
1414
1438
return inode ;
0 commit comments