hal: go from head of usecase list after removing offload usecase during ssr
When SSR is happening and the sound card is offline, after removing
an offload usecase from the usecase list, start traversing from the
beginning of the list on the next iteration. This must be done
because in the process of removing the current node from the list,
there is a moment in the time where another thread can remove the
node immediately after it which is also pointed to by tempnode
that is used by list_for_each_safe. This would result in tempnode
pointing to invalid memory on the next iteration of list_for_each_safe,
causing a segfault.
CRs-Fixed: 1088561
Change-Id: I8a220afa341c4e62612a809064754ddcd497d88a
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 1ea6754..40aea9a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4308,6 +4308,7 @@
pthread_mutex_unlock(&adev->lock);
out_standby(&out->stream.common);
pthread_mutex_lock(&adev->lock);
+ tempnode = list_head(&adev->usecase_list);
}
}
}