Skip to contentSkip to conversation

ASoC: rt5514-spi: Fix potential NULL pointer dereference

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jan 15, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt5514-spi: Fix potential NULL pointer dereference

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")
---
 sound/soc/codecs/rt5514-spi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/codecs/rt5514-spi.c +2 -0
index 4d46f4567c3a..bec2eefa8b0f 100644
@@ -280,6 +280,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 
 	rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
 			GFP_KERNEL);
+	if (!rt5514_dsp)
+		return -ENOMEM;
 
 	rt5514_dsp->dev = &rt5514_spi->dev;
 	mutex_init(&rt5514_dsp->dma_lock);
Signature · 1 line
2.20.1
maintainer
#1 lore raw

Applied "ASoC: rt5514-spi: Fix potential NULL pointer dereference" to the asoc tree

The patch

ASoC: rt5514-spi: Fix potential NULL pointer dereference

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 060d0bf491874daece47053c4e1fb0489eb867d2 Mon Sep 17 00:00:00 2001

From: "Gustavo A. R. Silva" <[email protected]>
Date: Tue, 15 Jan 2019 11:57:23 -0600
Subject: [PATCH] ASoC: rt5514-spi: Fix potential NULL pointer dereference

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")
---
 sound/soc/codecs/rt5514-spi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/codecs/rt5514-spi.c +2 -0
index 4d46f4567c3a..bec2eefa8b0f 100644
@@ -280,6 +280,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 
 	rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
 			GFP_KERNEL);
+	if (!rt5514_dsp)
+		return -ENOMEM;
 
 	rt5514_dsp->dev = &rt5514_spi->dev;
 	mutex_init(&rt5514_dsp->dma_lock);
Signature · 1 line
2.20.1