Skip to content

Commit 00fa1a8

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd/iova_bitmap: Consolidate iova_bitmap_set exit conditionals
There's no need to have two conditionals when they are closely tied together. Move the setting of bitmap::set_ahead_length after it checks for ::pages array out of bounds access. Link: https://lore.kernel.org/r/[email protected] 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 781bc08 commit 00fa1a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/iommu/iommufd/iova_bitmap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,18 +465,18 @@ void iova_bitmap_set(struct iova_bitmap *bitmap,
465465
last_bit - cur_bit + 1);
466466
void *kaddr;
467467

468-
if (unlikely(page_idx > last_page_idx))
468+
if (unlikely(page_idx > last_page_idx)) {
469+
unsigned long left =
470+
((last_bit - cur_bit + 1) << mapped->pgshift);
471+
472+
bitmap->set_ahead_length = left;
469473
break;
474+
}
470475

471476
kaddr = kmap_local_page(mapped->pages[page_idx]);
472477
bitmap_set(kaddr, offset, nbits);
473478
kunmap_local(kaddr);
474479
cur_bit += nbits;
475480
} while (cur_bit <= last_bit);
476-
477-
if (unlikely(cur_bit <= last_bit)) {
478-
bitmap->set_ahead_length =
479-
((last_bit - cur_bit + 1) << bitmap->mapped.pgshift);
480-
}
481481
}
482482
EXPORT_SYMBOL_NS_GPL(iova_bitmap_set, IOMMUFD);

0 commit comments

Comments
 (0)