summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2003-01-12 04:30:13 -0800
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2003-01-12 04:30:13 -0800
commitd6ad9ccabdbfe67730cffbc09264f7ba5876be08 (patch)
treec132422d7683129c29f79e9ee96fcc5f64fe302c /kernel
parentf7434ef49216be6c9fc5501610d2af5ad7f3746a (diff)
[PATCH] Fix strlen_user usage in module.c
strlen_user returns 0 on error, not an error number, and otherwise returns the length including the NUL byte. Found by Andi Kleen.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/module.c b/kernel/module.c
index bd289a331692..1d1c07a410c8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1096,17 +1096,17 @@ static struct module *load_module(void *umod,
mod = (void *)sechdrs[modindex].sh_addr;
/* Now copy in args */
- err = strlen_user(uargs);
- if (err < 0)
+ arglen = strlen_user(uargs);
+ if (!arglen) {
+ err = -EFAULT;
goto free_hdr;
- arglen = err;
-
- args = kmalloc(arglen+1, GFP_KERNEL);
+ }
+ args = kmalloc(arglen, GFP_KERNEL);
if (!args) {
err = -ENOMEM;
goto free_hdr;
}
- if (copy_from_user(args, uargs, arglen+1) != 0) {
+ if (copy_from_user(args, uargs, arglen) != 0) {
err = -EFAULT;
goto free_mod;
}