diff mbox series

ASoC: pxa: fix null-pointer dereference in filter()

Message ID 20221114085629.1910435-1-zengheng4@huawei.com (mailing list archive)
State Accepted
Commit ec7bf231aaa1bdbcb69d23bc50c753c80fb22429
Headers show
Series ASoC: pxa: fix null-pointer dereference in filter() | expand

Commit Message

Zeng Heng Nov. 14, 2022, 8:56 a.m. UTC
kasprintf() would return NULL pointer when kmalloc() fail to allocate.
Need to check the return pointer before calling strcmp().

Fixes: 7a824e214e25 ("ASoC: mmp: add audio dma support")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 sound/soc/pxa/mmp-pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown Nov. 15, 2022, 9:56 a.m. UTC | #1
On Mon, 14 Nov 2022 16:56:29 +0800, Zeng Heng wrote:
> kasprintf() would return NULL pointer when kmalloc() fail to allocate.
> Need to check the return pointer before calling strcmp().
> 
> 

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] ASoC: pxa: fix null-pointer dereference in filter()
      commit: ec7bf231aaa1bdbcb69d23bc50c753c80fb22429

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
diff mbox series

Patch

diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c
index 5d520e18e512..99b245e3079a 100644
--- a/sound/soc/pxa/mmp-pcm.c
+++ b/sound/soc/pxa/mmp-pcm.c
@@ -98,7 +98,7 @@  static bool filter(struct dma_chan *chan, void *param)
 
 	devname = kasprintf(GFP_KERNEL, "%s.%d", dma_data->dma_res->name,
 		dma_data->ssp_id);
-	if ((strcmp(dev_name(chan->device->dev), devname) == 0) &&
+	if (devname && (strcmp(dev_name(chan->device->dev), devname) == 0) &&
 		(chan->chan_id == dma_data->dma_res->start)) {
 		found = true;
 	}