diff --git a/arch/sim/src/sim/posix/sim_alsa.c b/arch/sim/src/sim/posix/sim_alsa.c index fbb8808917..440ef37993 100644 --- a/arch/sim/src/sim/posix/sim_alsa.c +++ b/arch/sim/src/sim/posix/sim_alsa.c @@ -560,11 +560,17 @@ static int sim_audio_stop(struct audio_lowerhalf_s *dev) priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK); #endif - apb_free(priv->aux); - priv->aux = NULL; + if (priv->aux) + { + apb_free(priv->aux); + priv->aux = NULL; + } - priv->ops->uninit(priv->codec); - priv->ops = NULL; + if (priv->ops) + { + priv->ops->uninit(priv->codec); + priv->ops = NULL; + } return 0; }