gkostka / lwext4

ext2/ext3/ext4 filesystem library for microcontrollers
http://sourceforge.net/projects/lwext4/
Other
491 stars 128 forks source link

Possible infinite loop in ext4_ialloc_alloc_inode() #50

Open rajeshvenkataraman opened 5 years ago

rajeshvenkataraman commented 5 years ago

In the ext4_ialloc_alloc_inode() inside the "while (bgid <= bg_count) " loop if the free_inodes is greater that zero and ext4_bmap_bit_find_clr() returns ENOSPC we continue to the top of the loop but the bgid is not incremented. This would lead to an infinite while loop.

                    /* Block group has not any free i-node */
                    if (rc == ENOSPC) {
                            rc = ext4_block_set(fs->bdev, &b);
                            if (rc != EOK) {
                                    ext4_fs_put_block_group_ref(&bg_ref);
                                    return rc;
                            }

                            rc = ext4_fs_put_block_group_ref(&bg_ref);
                            if (rc != EOK)
                                    return rc;

                            **++bgid;**
                            continue;
                    }