iommufd/selftest: Fix iommufd_test_dirty() to handle <u8 bitmaps
BugLink: https://bugs.launchpad.net/bugs/2083196
[ Upstream commit 9560393b830b415b2151b3dd8e065257cccbffa7 ]
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: Matt Ochs <mochs@nvidia.com>
Fixes: a9af47e382 ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP")
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Matt Ochs <mochs@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Portia Stephens <portia.stephens@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
48a66e1c0e
commit
259aca1b11
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user