Commit f8a60435 authored by Colin Ian King's avatar Colin Ian King Committed by Mark Brown

ASoC: rt5677: Add missing null check for failed allocation of rt5677_dsp

The allocation of rt5677_dsp can potentially fail and return null, so add
a null check and return -ENOMEM on a memory allocation failure.

Addresses-Coverity: ("Dereference null return")
Fixes: a0e0d135 ("ASoC: rt5677: Add a PCM device for streaming hotword via SPI")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20191024124610.18182-1-colin.king@canonical.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e42599d6
...@@ -376,6 +376,8 @@ static int rt5677_spi_pcm_probe(struct snd_soc_component *component) ...@@ -376,6 +376,8 @@ static int rt5677_spi_pcm_probe(struct snd_soc_component *component)
rt5677_dsp = devm_kzalloc(component->dev, sizeof(*rt5677_dsp), rt5677_dsp = devm_kzalloc(component->dev, sizeof(*rt5677_dsp),
GFP_KERNEL); GFP_KERNEL);
if (!rt5677_dsp)
return -ENOMEM;
rt5677_dsp->dev = &g_spi->dev; rt5677_dsp->dev = &g_spi->dev;
mutex_init(&rt5677_dsp->dma_lock); mutex_init(&rt5677_dsp->dma_lock);
INIT_DELAYED_WORK(&rt5677_dsp->copy_work, rt5677_spi_copy_work); INIT_DELAYED_WORK(&rt5677_dsp->copy_work, rt5677_spi_copy_work);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment