Skip to content

Commit 9560393

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd/selftest: Fix iommufd_test_dirty() to handle <u8 bitmaps
The calculation returns 0 if it sets less than the number of bits per byte. For calculating memory allocation from bits, lets round it up to one byte. Link: https://lore.kernel.org/r/[email protected] Reported-by: Matt Ochs <[email protected]> Fixes: a9af47e ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP") Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Tested-by: Matt Ochs <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent ec61f82 commit 9560393

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/iommufd/selftest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id,
13341334
}
13351335

13361336
max = length / page_size;
1337-
bitmap_size = max / BITS_PER_BYTE;
1337+
bitmap_size = DIV_ROUND_UP(max, BITS_PER_BYTE);
13381338

13391339
tmp = kvzalloc(bitmap_size, GFP_KERNEL_ACCOUNT);
13401340
if (!tmp) {

0 commit comments

Comments
 (0)