Commit 9560393b authored by Joao Martins's avatar Joao Martins Committed by Jason Gunthorpe
Browse files

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/20240627110105.62325-3-joao.m.martins@oracle.com


Reported-by: default avatarMatt Ochs <mochs@nvidia.com>
Fixes: a9af47e3 ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP")
Signed-off-by: default avatarJoao Martins <joao.m.martins@oracle.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Tested-by: default avatarMatt Ochs <mochs@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent ec61f820
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1334,7 +1334,7 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id,
	}

	max = length / page_size;
	bitmap_size = max / BITS_PER_BYTE;
	bitmap_size = DIV_ROUND_UP(max, BITS_PER_BYTE);

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