summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/link.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
commit48a0b31c478cb78dece459369610e0f993c8f6f0 (patch)
treef08fde80936619aa94f84edb0973878d8810d147 /Kernel/Syscalls/link.cpp
parent9903f5c6ef76dfd3c15e63205e307c9519c32ff3 (diff)
downloadserenity-48a0b31c478cb78dece459369610e0f993c8f6f0.zip
Kernel: Make copy_{from,to}_user() return KResult and use TRY()
This makes EFAULT propagation flow much more naturally. :^)
Diffstat (limited to 'Kernel/Syscalls/link.cpp')
-rw-r--r--Kernel/Syscalls/link.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Kernel/Syscalls/link.cpp b/Kernel/Syscalls/link.cpp
index f0b6e44ecf..9f47c4e0b0 100644
--- a/Kernel/Syscalls/link.cpp
+++ b/Kernel/Syscalls/link.cpp
@@ -15,8 +15,7 @@ KResultOr<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> u
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(cpath);
Syscall::SC_link_params params;
- if (!copy_from_user(&params, user_params))
- return EFAULT;
+ TRY(copy_from_user(&params, user_params));
auto old_path = TRY(try_copy_kstring_from_user(params.old_path));
auto new_path = TRY(try_copy_kstring_from_user(params.new_path));
return VirtualFileSystem::the().link(old_path->view(), new_path->view(), current_directory());
@@ -27,8 +26,7 @@ KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_para
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(cpath);
Syscall::SC_symlink_params params;
- if (!copy_from_user(&params, user_params))
- return EFAULT;
+ TRY(copy_from_user(&params, user_params));
auto target = TRY(get_syscall_path_argument(params.target));
auto linkpath = TRY(get_syscall_path_argument(params.linkpath));
return VirtualFileSystem::the().symlink(target->view(), linkpath->view(), current_directory());