Skip to contentSkip to conversation

ALSA: HDA: Fix Oops caused by dereference NULL pointer

PATCH Applied Wang YanQing 2 participants 2 messages May 7, 2013 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: HDA: Fix Oops caused by dereference NULL pointer

The interrupt handler azx_interrupt will call azx_update_rirb, which may call snd_hda_queue_unsol_event, snd_hda_queue_unsol_event will dereference chip->bus pointer.

The problem is we alloc chip->bus in azx_codec_create which will be called after we enable IRQ and enable unsolicited event in azx_probe.

This will cause Oops due dereference NULL pointer. I meet it, good luck:)

---
 sound/pci/hda/hda_codec.c | 3 +++
 1 file changed, 3 insertions(+)
sound/pci/hda/hda_codec.c +3 -0
index 622f726..9c76752 100644
@@ -618,6 +618,9 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
 	unsigned int wp;
 
 	trace_hda_unsol_event(bus, res, res_ex);
+	if (!bus)
+		return 0;
+
 	unsol = bus->unsol;
 	if (!unsol)
 		return 0;
Signature · 1 line
1.7.12.4.dirty
Applied
#1 lore raw

At Tue, 7 May 2013 11:27:33 +0800,

Quoted 5 lines · Wang YanQing

The interrupt handler azx_interrupt will call azx_update_rirb, which may call snd_hda_queue_unsol_event, snd_hda_queue_unsol_event will dereference chip->bus pointer.

Quoted 7 lines

The problem is we alloc chip->bus in azx_codec_create which will be called after we enable IRQ and enable unsolicited event in azx_probe.

This will cause Oops due dereference NULL pointer. I meet it, good luck:)

Thanks, applied with a slight fix (put before the tracepoint so that it won't give more NULL dereference, and also put another NULL check of bus->workq as done in hda_intel.c.)

Takashi

Quoted 21 lines
---
 sound/pci/hda/hda_codec.c | 3 +++
 1 file changed, 3 insertions(+)
sound/pci/hda/hda_codec.c +3 -0
index 622f726..9c76752 100644
@@ -618,6 +618,9 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
 	unsigned int wp;
 
 	trace_hda_unsol_event(bus, res, res_ex);
+	if (!bus)
+		return 0;
+
 	unsol = bus->unsol;
 	if (!unsol)
 		return 0;
Signature · 1 line
1.7.12.4.dirty