From e37e1da7b97ee4bca9f234d6f07c25a426c8bb64 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Tue, 24 May 2016 17:11:33 -0500 Subject: [PATCH] Update Callback to fix fault in serial interrupts Update the Callback class to handle a NULL thunk by returning 0 rather than trying to call the thunk. This fixes a crash that occurs on some targets when the TX uart handler is not attached. Background: The K64F HAL uart implementation calls the TX interrupt handler every time a uart interrupt occurs while the TX register is empty. It does not check to see if the TX interrupt has been enabled. This means that the TX interrupt can and typically does get run on RX events. This causes a crash with the newer callback code which did not (prior to this patch) support a NULL thunk. --- hal/api/Callback.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hal/api/Callback.h b/hal/api/Callback.h index fa1f5ecc3f..d7b4d12ec8 100644 --- a/hal/api/Callback.h +++ b/hal/api/Callback.h @@ -796,6 +796,9 @@ public: /** Call the attached function */ R call() { + if (NULL == _thunk) { + return (R)0; + } return _thunk(_obj, &_func); }