Skip to content

Commit 25148f5

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: Intel: avs: Add missing checks on FE startup
Constraint functions have return values, they should be checked for potential errors. Reviewed-by: Cezary Rojewski <[email protected]> Signed-off-by: Amadeusz Sławiński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 320f4d8 commit 25148f5

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

sound/soc/intel/avs/pcm.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,21 +468,34 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so
468468

469469
host_stream = snd_hdac_ext_stream_assign(bus, substream, HDAC_EXT_STREAM_TYPE_HOST);
470470
if (!host_stream) {
471-
kfree(data);
472-
return -EBUSY;
471+
ret = -EBUSY;
472+
goto err;
473473
}
474474

475475
data->host_stream = host_stream;
476-
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
476+
ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
477+
if (ret < 0)
478+
goto err;
479+
477480
/* avoid wrap-around with wall-clock */
478-
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME, 20, 178000000);
479-
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_rates);
481+
ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME, 20, 178000000);
482+
if (ret < 0)
483+
goto err;
484+
485+
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_rates);
486+
if (ret < 0)
487+
goto err;
488+
480489
snd_pcm_set_sync(substream);
481490

482491
dev_dbg(dai->dev, "%s fe STARTUP tag %d str %p",
483492
__func__, hdac_stream(host_stream)->stream_tag, substream);
484493

485494
return 0;
495+
496+
err:
497+
kfree(data);
498+
return ret;
486499
}
487500

488501
static void avs_dai_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)

0 commit comments

Comments
 (0)