]> git.baikalelectronics.ru Git - kernel.git/commit
ASoC: amd: Fix potential NULL pointer dereference
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 14 Jan 2019 23:40:10 +0000 (17:40 -0600)
committerMark Brown <broonie@kernel.org>
Tue, 15 Jan 2019 19:06:23 +0000 (19:06 +0000)
commitf482b8a77cb538c3d4a49c689f0ed5f1770006e9
tree22a94f05834a65bd8fca01cf2d087c0204339366
parent7dcc5e95a299ba03de2222960a7245c3875a6bab
ASoC: amd: Fix potential NULL pointer dereference

Check return value from call to devm_kzalloc() in order to prevent a
potential NULL pointer dereference.

Also, notice that it makes no sense to allocate any resources if
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); fails,
so move the call to devm_kzalloc() below the mentioned code.

Lastly, improve the use of sizeof in the call to devm_kzalloc() by
changing it from sizeof(struct i2s_dev_data) to sizeof(*adata)

This issue was detected with the help of Coccinelle.

Fixes: 102f6dea3928 ("ASoC: amd: add ACP3x PCM platform driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/amd/raven/acp3x-pcm-dma.c