From 9451dbecbb94e15b85aa24dfcf0a3fc4aff76a9f Mon Sep 17 00:00:00 2001 From: Larry Davis Date: Wed, 8 Jan 2020 10:32:16 -0800 Subject: [PATCH] fix: allocate multitouch interface correctly, fixes #7, fixes #3 * also check for the command gate so we don't try to do things after we've already stopped --- VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp | 2 +- VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp b/VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp index 8079cbd..4f6275c 100644 --- a/VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp +++ b/VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp @@ -203,7 +203,7 @@ void VoodooI2CGoodixEventDriver::handleStop(IOService* provider) { } IOReturn VoodooI2CGoodixEventDriver::publishMultitouchInterface() { - multitouch_interface = new VoodooI2CMultitouchInterface(); + multitouch_interface = OSTypeAlloc(VoodooI2CMultitouchInterface); if (!multitouch_interface) { IOLog("%s::No memory to allocate VoodooI2CMultitouchInterface instance\n", getName()); goto multitouch_exit; diff --git a/VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp b/VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp index f23a194..4e71412 100644 --- a/VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp +++ b/VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp @@ -235,6 +235,10 @@ void VoodooI2CGoodixTouchDriver::handle_input_threaded() { read_in_progress = false; return; } + if (!command_gate) { + read_in_progress = false; + return; + } command_gate->attemptAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooI2CGoodixTouchDriver::goodix_process_events)); read_in_progress = false; }