Merge "HAL: Fix for crash due to structure mismatch during st deinit"
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index 6fa7396..4ad65a6 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -166,13 +166,13 @@
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
bool online = state && !strcmp(state, "ONLINE");
- if (state)
- free(state);
#else
bool online = atoi(state);
#endif
ALOGV("card %d initial state %s %d", card, state, online);
+ if (state)
+ free(state);
s->status = online ? CARD_STATUS_ONLINE : CARD_STATUS_OFFLINE;
list_add_tail(&sndmonitor.cards, &s->node);