Skip to contentSkip to conversation

PATCH: linux-2.4.10-pre14/drivers/sound/maestro.c ignored pci_module_init results

PATCH Adam J. Richter 2 participants 2 messages Sep 23, 2001

lore
Share & tools
lore
#0 lore raw

The initialization routine in
linux-2.4.10-pre14/drivers/sound/maestro.c ignores the return value from pci_module_init, and allows module initialization to succeed even if pci_module_init failed. pci_module_init fails and unloads the driver if the caller is a module and there is no matching hardware. Because maestro.c ignored this failure, loading maestro.o on a system where the corresponding alsa driver was already loaded or on a system without matchin hardware would result in a kernel null pointer dereference in pci_unregister_driver when the module is unloaded or when one attempts to reboot the system (i.e., when the module attempt to unregister a PCI driver that is not registered).

This bug is also present in drivers/net/tlan.c and
drivers/net/irda/toshoboe.c. I will send patches for them shortly.

Here is the patch for maestro.c. Please apply.

Signature · 4 lines
Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."
drivers/sound/maestro.c +6 -1
@@ -3602,7 +3602,12 @@
 
 int __init init_maestro(void)
 {
-	pci_module_init(&maestro_pci_driver);
+	int rc;
+
+	rc = pci_module_init(&maestro_pci_driver);
+	if (rc < 0)
+		return rc;
+
 	if (register_reboot_notifier(&maestro_nb))
 		printk(KERN_WARNING "maestro: reboot notifier registration failed; may not reboot properly.\n");
 #ifdef MODULE
#1 lore raw
Quoted 4 lines · In article <[email protected]> you wrote:

--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Quoted 11 lines

The initialization routine in
linux-2.4.10-pre14/drivers/sound/maestro.c ignores the return value from pci_module_init, and allows module initialization to succeed even if pci_module_init failed. pci_module_init fails and unloads the driver if the caller is a module and there is no matching hardware. Because maestro.c ignored this failure, loading maestro.o on a system where the corresponding alsa driver was already loaded or on a system without matchin hardware would result in a kernel null pointer dereference in pci_unregister_driver when the module is unloaded or when one attempts to reboot the system (i.e., when the module attempt to unregister a PCI driver that is not registered).

Why and where does it Oops? The code for pci_unregister_driver in drivers/pci/pci.c looks correct and should not Oops.

The reboot notifier might be problematic, but I have not checked it.

Ciao, Marcus