Merge "hal: check the pointer before dereference"
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 59b46fc..a350198 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -753,7 +753,8 @@
         (const pthread_attr_t *) NULL, spkr_calibration_thread, &handle);
     } else {
         ALOGE("%s: thermal_client_request failed", __func__);
-        if (handle.thermal_client_handle)
+        if (handle.thermal_client_handle &&
+            handle.thermal_client_unregister_callback)
             handle.thermal_client_unregister_callback(handle.thermal_client_handle);
         if (handle.thermal_handle)
             dlclose(handle.thermal_handle);