From ef97fbd2220419afd03bddfbbc00755dcbc79783 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Fri, 6 Feb 2026 16:08:23 +0100 Subject: [PATCH] PR feedback --- TactilityKernel/Source/device.cpp | 2 ++ TactilityKernel/Source/driver.cpp | 2 +- TactilityKernel/Source/module.cpp | 7 +++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TactilityKernel/Source/device.cpp b/TactilityKernel/Source/device.cpp index cba6175d..9420b1db 100644 --- a/TactilityKernel/Source/device.cpp +++ b/TactilityKernel/Source/device.cpp @@ -74,9 +74,11 @@ error_t device_destruct(Device* device) { auto* internal = device->internal; if (internal->state.started || internal->state.added) { + unlock_internal(device->internal); return ERROR_INVALID_STATE; } if (!internal->children.empty()) { + unlock_internal(device->internal); return ERROR_INVALID_STATE; } LOG_D(TAG, "destruct %s", device->name); diff --git a/TactilityKernel/Source/driver.cpp b/TactilityKernel/Source/driver.cpp index c8da9169..9a05d6ec 100644 --- a/TactilityKernel/Source/driver.cpp +++ b/TactilityKernel/Source/driver.cpp @@ -51,7 +51,7 @@ error_t driver_destruct(Driver* driver) { } internal->destroying = true; - // Remove the internal reference before unlocking so it cannot be accidentally locked again + // Nullify internal reference before deletion to prevent use-after-free driver->internal = nullptr; delete internal; diff --git a/TactilityKernel/Source/module.cpp b/TactilityKernel/Source/module.cpp index c84b1f8a..51200f43 100644 --- a/TactilityKernel/Source/module.cpp +++ b/TactilityKernel/Source/module.cpp @@ -1,9 +1,9 @@ -#include -#include +#include #include +#include #include #include -#include +#include #define TAG "module" @@ -116,4 +116,3 @@ bool module_resolve_symbol_global(const char* symbol_name, uintptr_t* symbol_add } } -