Skip to content

Commit 2da2202

Browse files
committed
block: Fix incorrect boundary check for erase
1 parent 5460045 commit 2da2202

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util/block.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ static error_t
1919
partition_erase(struct block_iface *bi, size_t block, size_t count)
2020
{
2121
partition_t *p = (partition_t *)bi;
22-
block += p->offset;
23-
if (block + count > p->iface.num_blocks)
22+
if (block + count > p->iface.num_blocks) {
2423
return ERR_NOSPC;
24+
}
25+
block += p->offset;
2526
return p->parent->erase(p->parent, block, count);
2627
}
2728

0 commit comments

Comments
 (0)