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(). 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 --- 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) Jaroslav Kysela pointed out that better solution is --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -428,8 +428,10 @@ void bus_remove_device(struct device * d sysfs_remove_link(&dev->kobj, "bus"); sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); device_remove_attrs(dev->bus, dev); - dev->is_registered = 0; - klist_del(&dev->knode_bus); + if (dev->is_registered) { + dev->is_registered = 0; + klist_del(&dev->knode_bus); + } pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); device_release_driver(dev); put_bus(dev->bus); Acked-by: Jiri Kosina