hal: Avoid dereferencing null symbol pointer
Avoid a potential dereferencing of null symbol pointer returned from dlsym.
Change-Id: I92da03139c86f45d369e022ecae566be9dc236ea
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index aa541f0..c49d779 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -151,10 +151,9 @@
#define DLSYM(handle, ptr, symbol, err) \
do {\
- const char* error; \
- *(void**)&ptr = dlsym(handle, #symbol); \
- if ((error = dlerror())) {\
- ALOGE("%s: ERROR. %s", __func__, error);\
+ ptr = dlsym(handle, #symbol); \
+ if (ptr == NULL) {\
+ ALOGW("%s: %s not found. %s", __func__, #symbol, dlerror());\
err = -ENODEV;\
}\
} while(0)
@@ -633,7 +632,6 @@
}
ALOGI("%s: DLOPEN successful for %s", __func__, sound_trigger_lib);
- dlerror();
DLSYM(st_dev->lib_handle, st_dev->st_callback, sound_trigger_hw_call_back,
status);
if (status)