From 5027f347ffe6f719365ab13127106b52721676ff Mon Sep 17 00:00:00 2001 From: Adrian Knoth Date: Mon, 28 Feb 2011 15:14:49 +0100 Subject: [PATCH] ALSA: hdspm - Abort on unknown firmware revision Don't continue if we cannot detect the real card type, otherwise, all subsequent functions, especially strcpy(), would fail, leaving the whole driver in an unusable state. Without such a protection, dmesg would look like this: Pid: 1525, comm: modprobe Not tainted 2.6.38-rc6 #1 MSI MS-7250/MS-7250 EIP: 0060:[] EFLAGS: 00010296 CPU: 1 EIP is at strcpy+0x10/0x30 EAX: f4d33e58 EBX: f5990800 ECX: f4d33e58 EDX: 00000000 ESI: 00000000 EDI: f4d33e58 EBP: f5990930 ESP: f3dd3e0c DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 f53d4204 00000000 f90bfc03 00000001 00000001 f3dd3e64 c10fedff f3dd3e7c f3d854e4 f53d4000 c10307b8 00000001 c10307b8 f5990860 c10307b8 00000001 c10332e5 f59908bc c12f4339 f59908bc f5990860 c11ef207 f4d33e00 f53d4000 [] ? snd_hdspm_probe+0x7e7/0x1166 [snd_hdspm] [] ? __sysfs_add_one+0x1f/0xf0 [] ? get_parent_ip+0x8/0x20 [] ? get_parent_ip+0x8/0x20 [] ? get_parent_ip+0x8/0x20 [] ? add_preempt_count+0xa5/0xd0 [] ? _raw_spin_lock_irqsave+0x19/0x40 [] ? pm_runtime_enable+0x17/0x80 [] ? local_pci_probe+0x42/0xb0 [] ? pci_device_probe+0x61/0x80 [] ? driver_probe_device+0x77/0x180 [] ? pci_match_device+0xa0/0xc0 [] ? __driver_attach+0x79/0x80 [] ? __driver_attach+0x0/0x80 [] ? bus_for_each_dev+0x52/0x80 [] ? driver_attach+0x16/0x20 [] ? __driver_attach+0x0/0x80 [] ? bus_add_driver+0xa1/0x220 [] ? pci_device_remove+0x0/0xf0 [] ? driver_register+0x63/0x120 [] ? __pci_register_driver+0x3d/0xb0 [] ? do_one_initcall+0x32/0x160 [] ? alsa_card_hdspm_init+0x0/0x14 [snd_hdspm] [] ? sys_init_module+0x99/0x1e0 [] ? sys_close+0x6d/0xc0 [] ? sysenter_do_call+0x12/0x26 ---[ end trace 239f0661c558378b ]--- Signed-off-by: Adrian Knoth Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 20c54f7531a9..78f6ab5dbdd8 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6399,6 +6399,10 @@ static int __devinit snd_hdspm_create(struct snd_card *card, hdspm->card_name = "RME AES32"; hdspm->midiPorts = 2; break; + default: + snd_printk(KERN_ERR "HDSPM: unknown firmware revision %x\n", + hdspm->firmware_rev); + return -ENODEV; } err = pci_enable_device(pci); -- 2.30.2