All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: fix kernel panic in initialization of mpu401 driver
@ 2006-10-04 20:22 ` Jiri Kosina
  0 siblings, 0 replies; 35+ messages in thread
From: Jiri Kosina @ 2006-10-04 20:22 UTC (permalink / raw)
  To: Jaroslav Kysela, Castet Matthieu, Takashi Iwai
  Cc: Andrew Morton, alsa-devel, linux-kernel

I am getting kernel panic (NULL pointer dereference) on boot, with kernel 
compiled with CONFIG_SND_MPU401_UART=y, on machine which does not have 
this piece of hardware.

I have traced the problem down to 
sound/drivers/mpu401/mpu401.c:snd_mpu401_probe() returning EINVAL, when 
either port or IRQ parameters are not specified.

In such case, the drivers/base/bus.c:bus_attach_device() does not perform 
klist_add_tail() call, but rather sets dev->is_registered to 0. This flag 
is however not checked by the driver, so later on, when 
alsa_card_mpu401_init() is called and platform_device_register_simple() 
fails, the following callchain happens, causing NULL pointer dereference: 
alsa_card_mpu401_init() -> platform_device_unregister() -> 
platform_device_del() -> device_del() -> bus_remove_device() -> 
klist_del() -> BOOM (the entry was not added to klist in 
bus_attach_device()).

Proper solution is returning ENODEV from the ->probe() routine, which will 
be correctly handled then by the rest of the device-driver attaching 
subsystem (namely the retval check in bus_attach_device()). The following 
patch fixes the problem, please apply.

Patch against current Linus' git tree.

Signed-off-by: Jiri Kosina <jikos@jikos.cz>

--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -104,11 +104,11 @@ static int __devinit snd_mpu401_probe(st
 
 	if (port[dev] == SNDRV_AUTO_PORT) {
 		snd_printk(KERN_ERR "specify port\n");
-		return -EINVAL;
+		return -ENODEV;
 	}
 	if (irq[dev] == SNDRV_AUTO_IRQ) {
 		snd_printk(KERN_ERR "specify or disable IRQ\n");
-		return -EINVAL;
+		return -ENODEV;
 	}
 	err = snd_mpu401_create(dev, &card);
 	if (err < 0)

-- 
Jiri Kosina

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2006-10-13  6:36 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-04 20:22 [PATCH] ALSA: fix kernel panic in initialization of mpu401 driver Jiri Kosina
2006-10-04 20:22 ` Jiri Kosina
2006-10-05  8:07 ` Jaroslav Kysela
2006-10-05  8:07   ` Jaroslav Kysela
2006-10-05  9:57   ` Jiri Kosina
2006-10-05  9:57     ` Jiri Kosina
2006-10-05 14:02   ` Alan Stern
2006-10-05 14:02   ` Alan Stern
2006-10-05 14:16     ` Jaroslav Kysela
2006-10-05 17:58       ` Greg KH
2006-10-05 17:58         ` Greg KH
2006-10-05 21:03         ` [PATCH] Driver core: Don't ignore error returns from probing Alan Stern
2006-10-05 21:03           ` Alan Stern
2006-10-06  7:53           ` Cornelia Huck
2006-10-06  7:53             ` Cornelia Huck
2006-10-06  7:57             ` [PATCH] driver core: bus_attach_device() retval check Cornelia Huck
2006-10-06  9:41             ` [PATCH] Driver core: Don't ignore error returns from probing Jaroslav Kysela
2006-10-06  9:41               ` [Alsa-devel] " Jaroslav Kysela
2006-10-06 11:14               ` Cornelia Huck
2006-10-06 11:14                 ` [Alsa-devel] " Cornelia Huck
2006-10-06 11:46                 ` Jaroslav Kysela
2006-10-06 11:46                   ` [Alsa-devel] " Jaroslav Kysela
2006-10-06 18:12                 ` Alan Stern
2006-10-06 18:12                   ` [Alsa-devel] " Alan Stern
2006-10-09 11:10                   ` Cornelia Huck
2006-10-09 11:10                   ` [Alsa-devel] " Cornelia Huck
2006-10-09 11:14                   ` [PATCH] Driver core: Don't ignore bus_attach_device() retval Cornelia Huck
2006-10-09 14:10                     ` Alan Stern
2006-10-11 14:49                     ` Alan Stern
2006-10-12  9:30                       ` Cornelia Huck
2006-10-12 15:59                         ` Alan Stern
2006-10-12 17:17                           ` Cornelia Huck
2006-10-12 21:41                             ` Alan Stern
2006-10-13  6:37                               ` Cornelia Huck
2006-10-05 14:16     ` [PATCH] ALSA: fix kernel panic in initialization of mpu401 driver Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.