From 5cbf3654c74d17f194acb416a2179be00ba527c1 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Thu, 5 Dec 2024 13:08:04 -0500 Subject: [PATCH] spa: alsa: Add a NULL check before updating rate match The RateMatch IO might be NULL for the driver, and trying to update rate matching with state->rate_match crashes in this case. --- spa/plugins/alsa/alsa-pcm-sink.c | 3 ++- spa/plugins/alsa/alsa-pcm-source.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index 49e6ee557..c3edd3b19 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -757,7 +757,8 @@ impl_node_port_set_io(void *object, break; case SPA_IO_RateMatch: this->rate_match = data; - spa_alsa_update_rate_match(this); + if (this->rate_match) + spa_alsa_update_rate_match(this); break; default: return -ENOENT; diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index 5ee9a4c99..43356e526 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -687,7 +687,8 @@ impl_node_port_set_io(void *object, break; case SPA_IO_RateMatch: this->rate_match = data; - spa_alsa_update_rate_match(this); + if (this->rate_match) + spa_alsa_update_rate_match(this); break; default: return -ENOENT;