patch-2.1.79 linux/kernel/sysctl.c

Next file: linux/mm/filemap.c
Previous file: linux/kernel/sched.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.78/linux/kernel/sysctl.c linux/kernel/sysctl.c
@@ -435,12 +435,16 @@
 	return tmp;
 }
 
-void unregister_sysctl_table(struct ctl_table_header * table)
+/*
+ * Unlink and free a ctl_table.
+ */
+void unregister_sysctl_table(struct ctl_table_header * header)
 {
-	DLIST_DELETE(table, ctl_entry);
+	DLIST_DELETE(header, ctl_entry);
 #ifdef CONFIG_PROC_FS
-	unregister_proc_table(table->ctl_table, &proc_sys_root);
+	unregister_proc_table(header->ctl_table, &proc_sys_root);
 #endif
+	kfree(header);
 }
 
 /*
@@ -457,18 +461,20 @@
 	mode_t mode;
 	
 	for (; table->ctl_name; table++) {
-		de = 0;
 		/* Can't do anything without a proc name. */
 		if (!table->procname)
 			continue;
 		/* Maybe we can't do anything with it... */
-		if (!table->proc_handler &&
-		    !table->child)
+		if (!table->proc_handler && !table->child) {
+			printk(KERN_WARNING "SYSCTL: Can't register %s\n",
+				table->procname);
 			continue;
+		}
 
 		len = strlen(table->procname);
 		mode = table->mode;
 
+		de = NULL;
 		if (table->proc_handler)
 			mode |= S_IFREG;
 		else {
@@ -495,6 +501,9 @@
 	}
 }
 
+/*
+ * Unregister a /proc sysctl table and any subdirectories.
+ */
 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
 {
 	struct proc_dir_entry *de;
@@ -512,8 +521,11 @@
 		   entries... */
 		if (!((de->mode & S_IFDIR) && de->subdir)) {
 			proc_unregister(root, de->low_ino);
+			table->de = NULL;
 			kfree(de);
-		}
+		} else
+			printk("unregister_proc_table: %s not empty!\n",
+				table->procname);
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov