patch-2.3.30 linux/kernel/module.c

Next file: linux/kernel/resource.c
Previous file: linux/kernel/ksyms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.29/linux/kernel/module.c linux/kernel/module.c
@@ -111,11 +111,9 @@
 	long namelen, error;
 	struct module *mod;
 
+	if (!capable(CAP_SYS_MODULE))
+		return -EPERM;
 	lock_kernel();
-	if (!capable(CAP_SYS_MODULE)) {
-		error = -EPERM;
-		goto err0;
-	}
 	if ((namelen = get_mod_name(name_user, &name)) < 0) {
 		error = namelen;
 		goto err0;
@@ -162,13 +160,13 @@
 {
 	struct module mod_tmp, *mod;
 	char *name, *n_name;
-	long namelen, n_namelen, i, error = -EPERM;
+	long namelen, n_namelen, i, error;
 	unsigned long mod_user_size;
 	struct module_ref *dep;
 
-	lock_kernel();
 	if (!capable(CAP_SYS_MODULE))
-		goto err0;
+		return -EPERM;
+	lock_kernel();
 	if ((namelen = get_mod_name(name_user, &name)) < 0) {
 		error = namelen;
 		goto err0;
@@ -354,13 +352,13 @@
 {
 	struct module *mod, *next;
 	char *name;
-	long error = -EPERM;
+	long error;
 	int something_changed;
 
-	lock_kernel();
 	if (!capable(CAP_SYS_MODULE))
-		goto out;
+		return -EPERM;
 
+	lock_kernel();
 	if (name_user) {
 		if ((error = get_mod_name(name_user, &name)) < 0)
 			goto out;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)