From 48a0b31c478cb78dece459369610e0f993c8f6f0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 5 Sep 2021 17:38:37 +0200 Subject: Kernel: Make copy_{from,to}_user() return KResult and use TRY() This makes EFAULT propagation flow much more naturally. :^) --- Kernel/Arch/x86/common/Processor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Kernel/Arch') diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index dbf892c590..c7d29bbda4 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -476,10 +476,10 @@ Vector Processor::capture_stack_trace(Thread& thread, size_t max_frames break; if (Memory::is_user_range(VirtualAddress(stack_ptr), sizeof(FlatPtr) * 2)) { - if (!copy_from_user(&retaddr, &((FlatPtr*)stack_ptr)[1]) || !retaddr) + if (copy_from_user(&retaddr, &((FlatPtr*)stack_ptr)[1]).is_error() || !retaddr) break; stack_trace.append(retaddr); - if (!copy_from_user(&stack_ptr, (FlatPtr*)stack_ptr)) + if (copy_from_user(&stack_ptr, (FlatPtr*)stack_ptr).is_error()) break; } else { void* fault_at; @@ -552,7 +552,7 @@ Vector Processor::capture_stack_trace(Thread& thread, size_t max_frames auto& regs = thread.regs(); auto* stack_top = reinterpret_cast(regs.sp()); if (Memory::is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) { - if (!copy_from_user(&frame_ptr, &((FlatPtr*)stack_top)[0])) + if (copy_from_user(&frame_ptr, &((FlatPtr*)stack_top)[0]).is_error()) frame_ptr = 0; } else { void* fault_at; -- cgit v1.2.3