diff mbox series

ASoC: hdac_hda: Fix NULL pointer dereference when hda_pvt is not set

Message ID 20231212064533.233748-1-kai.heng.feng@canonical.com (mailing list archive)
State New, archived
Headers show
Series ASoC: hdac_hda: Fix NULL pointer dereference when hda_pvt is not set | expand

Commit Message

Kai-Heng Feng Dec. 12, 2023, 6:45 a.m. UTC
Kernel splat can be found on boot:
[    7.906438] BUG: kernel NULL pointer dereference, address: 0000000000000078
[    7.906449] #PF: supervisor read access in kernel mode
[    7.906455] #PF: error_code(0x0000) - not-present page
[    7.906461] PGD 0 P4D 0
[    7.906466] Oops: 0000 [#1] PREEMPT SMP NOPTI
[    7.906472] CPU: 15 PID: 109 Comm: kworker/15:0 Not tainted 6.7.0-rc5+ #9
[    7.906480] Hardware name: HP HP ZBook Fury 15 G7 Mobile Workstation/8783, BIOS S92 Ver. 01.15.00 10/03/2023
[    7.906489] Workqueue: events sof_probe_work [snd_sof]
[    7.906509] RIP: 0010:hdac_hda_dev_probe+0x48/0x110 [snd_soc_hdac_hda]

This is caused by attempting to dereference hda_pvt, so check if it's
NULL before using it.

Fixes: a0575b4add21 ("ASoC: hdac_hda: Conditionally register dais for HDMI and Analog")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 sound/soc/codecs/hdac_hda.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kai Vehmanen Dec. 12, 2023, 12:44 p.m. UTC | #1
Hi,

On Tue, 12 Dec 2023, Kai-Heng Feng wrote:

> Kernel splat can be found on boot:
> [    7.906438] BUG: kernel NULL pointer dereference, address: 0000000000000078
> [    7.906449] #PF: supervisor read access in kernel mode
> [    7.906455] #PF: error_code(0x0000) - not-present page
[...]
> This is caused by attempting to dereference hda_pvt, so check if it's
> NULL before using it.
> 
> Fixes: a0575b4add21 ("ASoC: hdac_hda: Conditionally register dais for HDMI and Analog")

can you try this fix already merged to Mark's tree (merged on 7th Dec):

"ASoC: SOF: Intel: hda-codec: Delay the codec device registration"
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?id=ce17aa4cf2db7d6b95a3f854ac52d0d49881dd49

Br, Kai
Kai-Heng Feng Dec. 13, 2023, 1:59 a.m. UTC | #2
Hi,

On Tue, Dec 12, 2023 at 8:45 PM Kai Vehmanen
<kai.vehmanen@linux.intel.com> wrote:
>
> Hi,
>
> On Tue, 12 Dec 2023, Kai-Heng Feng wrote:
>
> > Kernel splat can be found on boot:
> > [    7.906438] BUG: kernel NULL pointer dereference, address: 0000000000000078
> > [    7.906449] #PF: supervisor read access in kernel mode
> > [    7.906455] #PF: error_code(0x0000) - not-present page
> [...]
> > This is caused by attempting to dereference hda_pvt, so check if it's
> > NULL before using it.
> >
> > Fixes: a0575b4add21 ("ASoC: hdac_hda: Conditionally register dais for HDMI and Analog")
>
> can you try this fix already merged to Mark's tree (merged on 7th Dec):
>
> "ASoC: SOF: Intel: hda-codec: Delay the codec device registration"
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?id=ce17aa4cf2db7d6b95a3f854ac52d0d49881dd49

Yes this commit fixes the issue. Thanks!

Kai-Heng

>
> Br, Kai
diff mbox series

Patch

diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c
index b075689db2dc..abc214f201a8 100644
--- a/sound/soc/codecs/hdac_hda.c
+++ b/sound/soc/codecs/hdac_hda.c
@@ -632,7 +632,7 @@  static int hdac_hda_dev_probe(struct hdac_device *hdev)
 	snd_hdac_ext_bus_link_get(hdev->bus, hlink);
 
 	/* ASoC specific initialization */
-	if (hda_pvt->need_display_power)
+	if (hda_pvt && hda_pvt->need_display_power)
 		ret = devm_snd_soc_register_component(&hdev->dev,
 						&hdac_hda_hdmi_codec, hdac_hda_hdmi_dais,
 						ARRAY_SIZE(hdac_hda_hdmi_dais));