Skip to contentSkip to conversation

Patch - bug in adding/removing modules

PATCH Matthew Tippett 1 participant 1 message Dec 15, 2002 ACPI

lore
Share & tools
lore
#0 lore raw

Although I was only looking at the battery module, I believe I have fixed a potential oops regarding inserting and removing modules.

The attached patch fixes a problem that I have seen, a quick look at other modules seems to have the same problem.

The description of the problem is ...

There is a macro called acpi_device_dir which returns a pointer to the a battery instance directory in /proc/acpi/battery. When removing a module, the device is removed from the proc heirachy, but the entry in the device table is never set to null. So consequently when the device is reinserted the add_fs call already sees the proc directory entry and consequently uses the /proc/acpi/battery and along the way corrupts some memory.

So the patch NULLs out the proc dir entry in the device structure in a manner symmetric with the creation and deletion of the proc directory.

Regards,

Matthew

Signature · 3 lines
Matthew Tippett - [email protected] - (416) 435-4118
Technology Forum - http://www.technology-forum.org/
Commercial Open Source - http://www.commercialos.org/
battery.c renamed from battery.c.orig +3 -1
@@ -658,8 +658,10 @@
 {
 	ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
 
-	if (acpi_device_dir(device)) 
+	if (acpi_device_dir(device)) {
 		remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
+		acpi_device_dir(device) = NULL;
+	}
 
 	return_VALUE(0);
 }