ext4: fix hang when processing corrupted orphaned inode list
[pandora-kernel.git] / fs / ext4 / ialloc.c
index 6d1f577..476caae 100644 (file)
@@ -813,6 +813,10 @@ got:
                struct buffer_head *block_bitmap_bh;
 
                block_bitmap_bh = ext4_read_block_bitmap(sb, group);
+               if (!block_bitmap_bh) {
+                       err = -EIO;
+                       goto out;
+               }
                BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
                err = ext4_journal_get_write_access(handle, block_bitmap_bh);
                if (err) {
@@ -995,11 +999,13 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
                goto iget_failed;
 
        /*
-        * If the orphans has i_nlinks > 0 then it should be able to be
-        * truncated, otherwise it won't be removed from the orphan list
-        * during processing and an infinite loop will result.
+        * If the orphans has i_nlinks > 0 then it should be able to
+        * be truncated, otherwise it won't be removed from the orphan
+        * list during processing and an infinite loop will result.
+        * Similarly, it must not be a bad inode.
         */
-       if (inode->i_nlink && !ext4_can_truncate(inode))
+       if ((inode->i_nlink && !ext4_can_truncate(inode)) ||
+           is_bad_inode(inode))
                goto bad_orphan;
 
        if (NEXT_ORPHAN(inode) > max_ino)