ASoC: rt5514-spi: Fix potential NULL pointer dereference
diff mbox series

Message ID 20190115175723.GA32176@embeddedor
State Accepted
Commit 060d0bf491874daece47053c4e1fb0489eb867d2
Headers show
  • ASoC: rt5514-spi: Fix potential NULL pointer dereference
Related show

Commit Message

Gustavo A. R. Silva Jan. 15, 2019, 5:57 p.m. UTC
There is a potential NULL pointer dereference in case devm_kzalloc()
fails and returns NULL.

Fix this by adding a NULL check on rt5514_dsp.

This issue was detected with the help of Coccinelle.

Fixes: 6eebf35b0e4a ("ASoC: rt5514: add rt5514 SPI driver")
Signed-off-by: Gustavo A. R. Silva <>
 sound/soc/codecs/rt5514-spi.c | 2 ++
 1 file changed, 2 insertions(+)

diff mbox series

diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 4d46f4567c3a..bec2eefa8b0f 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -280,6 +280,8 @@  static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 	rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
+	if (!rt5514_dsp)
+		return -ENOMEM;
 	rt5514_dsp->dev = &rt5514_spi->dev;