summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/rt5677-spi.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-10-24 15:46:10 +0300
committerMark Brown <broonie@kernel.org>2019-10-25 13:05:47 +0300
commitf8a60435703bdde8f8a0ceb1aa8dad59df821583 (patch)
treeb6d14df605ddc541bb927f2457aa4dcb4ab7e185 /sound/soc/codecs/rt5677-spi.c
parente42599d6bbf5aa48ae8a2942946b0f6194017fdf (diff)
downloadlinux-f8a60435703bdde8f8a0ceb1aa8dad59df821583.tar.xz
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: a0e0d135427c ("ASoC: rt5677: Add a PCM device for streaming hotword via SPI") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20191024124610.18182-1-colin.king@canonical.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt5677-spi.c')
-rw-r--r--sound/soc/codecs/rt5677-spi.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c
index 36c02d200cfc..3a17643fcd9f 100644
--- a/sound/soc/codecs/rt5677-spi.c
+++ b/sound/soc/codecs/rt5677-spi.c
@@ -376,6 +376,8 @@ static int rt5677_spi_pcm_probe(struct snd_soc_component *component)
rt5677_dsp = devm_kzalloc(component->dev, sizeof(*rt5677_dsp),
GFP_KERNEL);
+ if (!rt5677_dsp)
+ return -ENOMEM;
rt5677_dsp->dev = &g_spi->dev;
mutex_init(&rt5677_dsp->dma_lock);
INIT_DELAYED_WORK(&rt5677_dsp->copy_work, rt5677_spi_copy_work);