ANDROID: ASoC: core: Fix soc_pcm_hw_params crash

In testing some db845c audio patches, I came across a crash (see
below) that I only could reproduce on android-mainline and not
with Linus' tree.

I chased down the issue to a null pointer traversal that was
introduced commit 9cb7ec3e9b ("ANDROID: ASoC: core - add
hostless DAI support").

This patch adds an extra check to avoid the null traversal

[   74.058167] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
...
[   74.130054] Hardware name: Thundercomm Dragonboard 845c (DT)
[   74.135777] pstate: 80400005 (Nzcv daif +PAN -UAO)
[   74.140639] pc : soc_pcm_hw_params+0x194/0x690
[   74.145141] lr : soc_pcm_hw_params+0x88/0x690
[   74.149544] sp : ffffffc01249b9d0
...
[   74.233392] Call trace:
[   74.235878]  soc_pcm_hw_params+0x194/0x690
[   74.240028]  dpcm_fe_dai_hw_params+0xb0/0x130
[   74.244435]  snd_pcm_hw_params+0xf8/0x3f8
[   74.248492]  snd_pcm_ioctl_hw_params_compat+0x148/0x288
[   74.253769]  snd_pcm_ioctl_compat+0x764/0x8c8
[   74.258178]  __arm64_compat_sys_ioctl+0xf4/0x110
[   74.262850]  el0_svc_common.constprop.2+0x78/0x188
[   74.267698]  do_el0_svc_compat+0x2c/0x38
[   74.271666]  el0_sync_compat_handler+0x130/0x180
[   74.276334]  el0_sync_compat+0x144/0x180
[   74.280306] Code: 12000400 7100041f 54002120 f9403420 (f9400802)
[   74.286464] ---[ end trace 3c2126d28e1f9af7 ]---
[   74.291131] Kernel panic - not syncing: Fatal exception

Fixes: 9cb7ec3e9b ("ANDROID: ASoC: core - add hostless DAI support")
Change-Id: Ib7addfee4ac7382824fcc12057b93a956e6ae5f4
Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
John Stultz
2020-02-29 03:39:18 +00:00
committed by Matthias Maennich
parent 4389091ece
commit 89ff7d0c86

View File

@@ -891,7 +891,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
rtd->dai_link->name);
}
if (rtd->dai_link->ops->hw_params) {
if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) {
ret = rtd->dai_link->ops->hw_params(substream, params);
if (ret < 0) {
dev_err(rtd->card->dev, "ASoC: machine hw_params"