From 4befc2c28200b0d2df293c2f46519e4adb0aa9c0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 15 Dec 2020 11:25:51 +0100 Subject: [PATCH] Kernel: Avoid null dereference in sys$profiling_disable() If we can't create a profiling coredump object, we shouldn't try to call write() on it. --- Kernel/Syscalls/profiling.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel/Syscalls/profiling.cpp b/Kernel/Syscalls/profiling.cpp index d49516c4fdf..10a11a9dd60 100644 --- a/Kernel/Syscalls/profiling.cpp +++ b/Kernel/Syscalls/profiling.cpp @@ -60,8 +60,10 @@ int Process::sys$profiling_disable(pid_t pid) // We explicitly unlock here because we can't hold the lock when writing the coredump VFS lock.unlock(); - auto coredump = CoreDump::create(*process, String::formatted("/tmp/profiler_coredumps/{}", pid)); - coredump->write(); + if (auto coredump = CoreDump::create(*process, String::formatted("/tmp/profiler_coredumps/{}", pid))) + coredump->write(); + else + dbgln("Unable to create profiler coredump for PID {}", pid); return 0; }