Skip to content

Commit

Permalink
mm: kmsan: use helper macro offset_in_page()
Browse files Browse the repository at this point in the history
Use helper macro offset_in_page() to improve code readability.  No
functional modification involved.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: ZhangPeng <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Kefeng Wang <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: Nanyong Sun <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
ZhangPeng authored and akpm00 committed Aug 21, 2023
1 parent 5d7800d commit 4852a80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mm/kmsan/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void kmsan_handle_dma(struct page *page, size_t offset, size_t size,
* internal KMSAN checks.
*/
while (size > 0) {
page_offset = addr % PAGE_SIZE;
page_offset = offset_in_page(addr);
to_go = min(PAGE_SIZE - page_offset, (u64)size);
kmsan_handle_dma_page((void *)addr, to_go, dir);
addr += to_go;
Expand Down
2 changes: 1 addition & 1 deletion mm/kmsan/shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void *kmsan_get_metadata(void *address, bool is_origin)
return NULL;
if (!page_has_metadata(page))
return NULL;
off = addr % PAGE_SIZE;
off = offset_in_page(addr);

return (is_origin ? origin_ptr_for(page) : shadow_ptr_for(page)) + off;
}
Expand Down

0 comments on commit 4852a80

Please sign in to comment.