lkml.org 
[lkml]   [2013]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v3] kernel/itimer.c: remove the checking 'value' statement

Since copy_to_user() will process "bad address" internally, we need not
check 'value' again, then can save one comparing instruction at least.

For some embedded system with NOMMU, 'NULL' may not mean "bad address"
(EFAULT), so recommend to let copy_to_user() to check 'EFAULT' in this
case, completely.

Removing the checking code, also can let it simpler and clearer to
readers.


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
kernel/itimer.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/itimer.c b/kernel/itimer.c
index 8d262b4..3b12271 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -102,15 +102,14 @@ int do_getitimer(int which, struct itimerval *value)

SYSCALL_DEFINE2(getitimer, int, which, struct itimerval __user *, value)
{
- int error = -EFAULT;
+ int error;
struct itimerval get_buffer;

- if (value) {
- error = do_getitimer(which, &get_buffer);
- if (!error &&
- copy_to_user(value, &get_buffer, sizeof(get_buffer)))
- error = -EFAULT;
- }
+ error = do_getitimer(which, &get_buffer);
+ if (!error &&
+ copy_to_user(value, &get_buffer, sizeof(get_buffer)))
+ error = -EFAULT;
+
return error;
}

--
1.7.7.6


\
 
 \ /
  Last update: 2013-06-21 12:41    [W:0.059 / U:0.888 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site