@@ -2613,7 +2613,7 @@ void dtInitRoot(tid_t tid, struct inode *ip, u32 idotdot)
2613
2613
* fsck.jfs should really fix this, but it currently does not.
2614
2614
* Called from jfs_readdir when bad index is detected.
2615
2615
*/
2616
- static void add_missing_indices (struct inode * inode , s64 bn )
2616
+ static int add_missing_indices (struct inode * inode , s64 bn )
2617
2617
{
2618
2618
struct ldtentry * d ;
2619
2619
struct dt_lock * dtlck ;
@@ -2622,7 +2622,7 @@ static void add_missing_indices(struct inode *inode, s64 bn)
2622
2622
struct lv * lv ;
2623
2623
struct metapage * mp ;
2624
2624
dtpage_t * p ;
2625
- int rc ;
2625
+ int rc = 0 ;
2626
2626
s8 * stbl ;
2627
2627
tid_t tid ;
2628
2628
struct tlock * tlck ;
@@ -2647,6 +2647,16 @@ static void add_missing_indices(struct inode *inode, s64 bn)
2647
2647
2648
2648
stbl = DT_GETSTBL (p );
2649
2649
for (i = 0 ; i < p -> header .nextindex ; i ++ ) {
2650
+ if (stbl [i ] < 0 ) {
2651
+ jfs_err ("jfs: add_missing_indices: Invalid stbl[%d] = %d for inode %ld, block = %lld" ,
2652
+ i , stbl [i ], (long )inode -> i_ino , (long long )bn );
2653
+ rc = - EIO ;
2654
+
2655
+ DT_PUTPAGE (mp );
2656
+ txAbort (tid , 0 );
2657
+ goto end ;
2658
+ }
2659
+
2650
2660
d = (struct ldtentry * ) & p -> slot [stbl [i ]];
2651
2661
index = le32_to_cpu (d -> index );
2652
2662
if ((index < 2 ) || (index >= JFS_IP (inode )-> next_index )) {
@@ -2664,6 +2674,7 @@ static void add_missing_indices(struct inode *inode, s64 bn)
2664
2674
(void ) txCommit (tid , 1 , & inode , 0 );
2665
2675
end :
2666
2676
txEnd (tid );
2677
+ return rc ;
2667
2678
}
2668
2679
2669
2680
/*
@@ -3017,7 +3028,8 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
3017
3028
}
3018
3029
3019
3030
if (fix_page ) {
3020
- add_missing_indices (ip , bn );
3031
+ if ((rc = add_missing_indices (ip , bn )))
3032
+ goto out ;
3021
3033
page_fixed = 1 ;
3022
3034
}
3023
3035
0 commit comments