mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
Kernel: Use already computed nfds_checked value when copying from user mode.
- We've already computed the number of fds * sizeof(pollfd), so use it instead of needlessly doing it again. - Use fds_copy.data() instead off address of indexing the vector.
This commit is contained in:
parent
1c0e2947d7
commit
4743afeaf4
1 changed files with 2 additions and 2 deletions
|
@ -169,7 +169,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
|
|||
if (nfds_checked.has_overflow())
|
||||
return -EFAULT;
|
||||
fds_copy.resize(params.nfds);
|
||||
if (!copy_from_user(&fds_copy[0], ¶ms.fds[0], params.nfds * sizeof(pollfd)))
|
||||
if (!copy_from_user(fds_copy.data(), ¶ms.fds[0], nfds_checked.value()))
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
|
|||
fds_with_revents++;
|
||||
}
|
||||
|
||||
if (params.nfds > 0 && !copy_to_user(¶ms.fds[0], &fds_copy[0], params.nfds * sizeof(pollfd)))
|
||||
if (params.nfds > 0 && !copy_to_user(¶ms.fds[0], fds_copy.data(), params.nfds * sizeof(pollfd)))
|
||||
return -EFAULT;
|
||||
|
||||
return fds_with_revents;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue