Skip to content

Commit 03e198a

Browse files
committed
alsa: clean up followers and our driver link in _clear
When we are going to be freed, make sure we remove ourself from the driver list and also remove all the followers that we might still have. Fixes #4355
1 parent f5d544d commit 03e198a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spa/plugins/alsa/alsa-pcm.c

+18
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,28 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
878878
int spa_alsa_clear(struct state *state)
879879
{
880880
int err;
881+
struct state *follower;
881882

882883
spa_list_remove(&state->link);
883884
release_card(state->card);
884885

886+
if (state->driver != NULL) {
887+
spa_list_remove(&state->driver_link);
888+
state->driver = NULL;
889+
}
890+
if (state->rt.driver != NULL) {
891+
spa_list_remove(&state->rt.driver_link);
892+
state->rt.driver = NULL;
893+
}
894+
spa_list_consume(follower, &state->followers, driver_link) {
895+
spa_list_remove(&follower->driver_link);
896+
follower->driver = NULL;
897+
}
898+
spa_list_consume(follower, &state->rt.followers, rt.driver_link) {
899+
spa_list_remove(&follower->rt.driver_link);
900+
follower->rt.driver = NULL;
901+
}
902+
885903
state->card = NULL;
886904
state->card_index = SPA_ID_INVALID;
887905

0 commit comments

Comments
 (0)