mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
fsck_msdosfs: fix head bitmap over-allocation on 32-bit platforms
bitmap_ctor() computed the allocation size as roundup2(bits, LONG_BIT) / (LONG_BIT / 8) The dividend is a count of bits, so converting it to bytes requires dividing by 8 (bits per byte), not by LONG_BIT / 8 (bytes per long). The two divisors happen to coincide on LP64, but on ILP32 platforms the head bitmap was allocated at twice the required size; for a FAT32 file system with close to 2^28 clusters, that is 64 MiB instead of 32 MiB. The extra half of the allocation was never accessed, so there is no functional change other than the reduced memory footprint. MFC after: 3 days Pull Request: https://github.com/freebsd/freebsd-src/pull/2440
This commit is contained in:
1 parent
10bd16d4e8
commit
269002da45
1 file changed
+1
-1
@@ -121,7 +121,7 @@ bitmap_count(long_bitmap_t *lbp)
|
||||
static int
|
||||
bitmap_ctor(long_bitmap_t *lbp, size_t bits, bool allone)
|
||||
{
|
||||
size_t bitmap_size = roundup2(bits, LONG_BIT) / (LONG_BIT / 8);
|
||||
size_t bitmap_size = roundup2(bits, LONG_BIT) / 8;
|
||||
|
||||
free(lbp->map);
|
||||
lbp->map = calloc(1, bitmap_size);
|
||||
|
||||
Reference in new issue
Block a user