]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
authorCodrin Ciubotariu <codrin.ciubotariu@microchip.com>
Mon, 7 Mar 2022 12:21:57 +0000 (14:21 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 8 Mar 2022 13:38:56 +0000 (13:38 +0000)
Even if struct snd_dmaengine_pcm_config is used, prepare_slave_config()
callback might not be set. Check if this callback is set before using it.

Fixes: 05a22446b008 ("ASoC: dmaengine-pcm: Provide default config")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Link: https://lore.kernel.org/r/20220307122202.2251639-2-codrin.ciubotariu@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-generic-dmaengine-pcm.c

index 285441d6aeed475044901c414fe507b745386475..2ab2ddc1294dd51e4f52d54fbfb5564c726ceba5 100644 (file)
@@ -86,10 +86,10 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
 
        memset(&slave_config, 0, sizeof(slave_config));
 
-       if (!pcm->config)
-               prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
-       else
+       if (pcm->config && pcm->config->prepare_slave_config)
                prepare_slave_config = pcm->config->prepare_slave_config;
+       else
+               prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
 
        if (prepare_slave_config) {
                int ret = prepare_slave_config(substream, params, &slave_config);