Skip to content

Fix offset within page calculation #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CrabJournal
Copy link

In Linux kernel since commit torvalds/linux@e2b39df property "offset" is exported, but it was just mem->addr & ~PAGE_MASK until commit torvalds/linux@171058f when addr became "rounded to page size" and offset became a field of struct uio_mem. But in uio_pdrv_genirq until commit torvalds/linux@7aca462 addr wasn't rounded by page size and field offset wasn't even initialized. Memory to struct where uio_mem is allocated by kzalloc so offset was 0.

In this commit offset calculated as addr & (getpagesize () - 1) if:

  1. file "offset" doesn't exist
  2. 0 was read from file "offset"

In Linux kernel since commit torvalds/linux@e2b39df property "offset" is exported,
but it was just `mem->addr & ~PAGE_MASK` until commit torvalds/linux@171058f when
`addr` became "rounded to page size" and `offset` became a field of `struct uio_mem`.
But in uio_pdrv_genirq until commit torvalds/linux@7aca462 `addr` wasn't rounded by
page size and field `offset` wasn't even initialized. Memory to struct where uio_mem
is allocated by kzalloc so offset was 0.

In this commit `offset` calculated as `addr & (getpagesize () - 1)` if:
1) file "offset" doesn't exist
2) 0 was read from file "offset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant