Skip to contentSkip to conversation

minor bugfix agains ext2

PATCH New Alex Tomas 1 participant 1 message Mar 12, 2003 ext2 file system

lore
Share & tools
lore

Alex Tomas

author
#0 lore raw

PATCH 1/1 minor bugfix agains ext2

Hi!

looks like following code in 2.5.64 has bug:

        for (bit = 0; !group_alloc &&
                        bit < sbi->s_groups_count; bit++) {
                group_no++;
                if (group_no >= sbi->s_groups_count)
                        group_no = 0;
                desc = ext2_get_group_desc(sb, group_no, &gdp_bh);
                if (!desc)
                        goto io_error;
                group_alloc = group_reserve_blocks(desc, gdp_bh, es_alloc);
        }
        if (bit >= sbi->s_groups_count) {
                *err = -ENOSPC;
                goto out_release;
        }

if group_reserve_blocks() finds free blocks on last repeat then if (bit >= ...) will be true, and ext2_new_block() will return -ENOSPC.

here is the patch:

balloc.c renamed from fs/ext2/balloc.c +1 -1
@@ -395,7 +395,7 @@
 			goto io_error;
 		group_alloc = group_reserve_blocks(desc, gdp_bh, es_alloc);
 	}
-	if (bit >= sbi->s_groups_count) {
+	if (!group_alloc) {
 		*err = -ENOSPC;
 		goto out_release;
 	}