/dev/zero: avoid repeated access_ok() checks
authorNikanth Karthikesan <knikanth@suse.de>
Wed, 23 Sep 2009 22:57:09 +0000 (15:57 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Sep 2009 14:21:03 +0000 (07:21 -0700)
In read_zero, we check for access_ok() once for the count bytes.  It is
unnecessarily checked again in clear_user.  Use __clear_user, which does
not check for access_ok().

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/mem.c

index 0aede1d6a9eaa28a843274793ddc0af54e492962..6c8b65d069e514badcab1b70c6032fea129b2bc7 100644 (file)
@@ -690,7 +690,7 @@ static ssize_t read_zero(struct file * file, char __user * buf,
 
                if (chunk > PAGE_SIZE)
                        chunk = PAGE_SIZE;      /* Just for latency reasons */
-               unwritten = clear_user(buf, chunk);
+               unwritten = __clear_user(buf, chunk);
                written += chunk - unwritten;
                if (unwritten)
                        break;