From 57070d012cd425c3a71663528c56a436abd2d9da Mon Sep 17 00:00:00 2001 From: Peter Staubach Date: Sat, 25 Mar 2006 03:08:04 -0800 Subject: [PATCH] compat_sys_nfsservctl(): handle errors correctly Correct some error handling on the compat version of the nfsservctl() system. It was detecting errors while copying in the arguments from user space, but then attempting to use the arguments anyway. This didn't seem so good. Signed-off-by: Peter Staubach Cc: Trond Myklebust Cc: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/compat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'fs/compat.c') diff --git a/fs/compat.c b/fs/compat.c index 2a88477..263990a 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -2170,9 +2170,12 @@ asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user * default: err = -EINVAL; - goto done; + break; } + if (err) + goto done; + oldfs = get_fs(); set_fs(KERNEL_DS); /* The __user pointer casts are valid because of the set_fs() */ -- cgit v1.1 From 11b0b5abb2097a63c1081d9b7e825b987b227972 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Sat, 25 Mar 2006 03:08:13 -0800 Subject: [PATCH] use kzalloc and kcalloc in core fs code Signed-off-by: Oliver Neukum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/compat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'fs/compat.c') diff --git a/fs/compat.c b/fs/compat.c index 263990a..ef5a077 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1476,10 +1476,9 @@ int compat_do_execve(char * filename, int i; retval = -ENOMEM; - bprm = kmalloc(sizeof(*bprm), GFP_KERNEL); + bprm = kzalloc(sizeof(*bprm), GFP_KERNEL); if (!bprm) goto out_ret; - memset(bprm, 0, sizeof(*bprm)); file = open_exec(filename); retval = PTR_ERR(file); -- cgit v1.1 From 68c3431ae22912be580c68d3955ef46515582943 Mon Sep 17 00:00:00 2001 From: Vadim Lobanov Date: Tue, 28 Mar 2006 01:56:35 -0800 Subject: [PATCH] Fold select_bits_alloc/free into caller code. Remove an unnecessary level of indirection in allocating and freeing select bits, as per the select_bits_alloc() and select_bits_free() functions. Both select.c and compat.c are updated. Signed-off-by: Vadim Lobanov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/compat.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'fs/compat.c') diff --git a/fs/compat.c b/fs/compat.c index ef5a077..7f8e26e 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1639,15 +1639,6 @@ void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, * This is a virtual copy of sys_select from fs/select.c and probably * should be compared to it from time to time */ -static void *select_bits_alloc(int size) -{ - return kmalloc(6 * size, GFP_KERNEL); -} - -static void select_bits_free(void *bits, int size) -{ - kfree(bits); -} /* * We can actually return ERESTARTSYS instead of EINTR, but I'd @@ -1686,7 +1677,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, */ ret = -ENOMEM; size = FDS_BYTES(n); - bits = select_bits_alloc(size); + bits = kmalloc(6 * size, GFP_KERNEL); if (!bits) goto out_nofds; fds.in = (unsigned long *) bits; @@ -1720,7 +1711,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, compat_set_fd_set(n, exp, fds.res_ex); out: - select_bits_free(bits, size); + kfree(bits); out_nofds: return ret; } -- cgit v1.1