From: Olof Johansson <olof@lixom.net>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: Confused about usercopy_64.c
Date: Mon, 10 Mar 2008 11:50:17 -0500 [thread overview]
Message-ID: <20080310165017.GA24812@lixom.net> (raw)
In-Reply-To: <47D56419.6000704@freescale.com>
On Mon, Mar 10, 2008 at 11:38:49AM -0500, Timur Tabi wrote:
> I'm confused about something in usercopy_64.c:
>
> unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
> {
> if (likely(access_ok(VERIFY_READ, from, n)))
> n = __copy_from_user(to, from, n);
> else
> memset(to, 0, n);
> return n;
> }
>
> If access_ok() returns false, then that means that we cannot copy the data from
> user-space. So why are we returning 'n'? Shouldn't we return zero, to let the
> caller know that the function failed?
copy_from_user() returns number of bytes _not_ copied.
-Olof
next prev parent reply other threads:[~2008-03-10 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-10 16:38 Confused about usercopy_64.c Timur Tabi
2008-03-10 16:50 ` Olof Johansson [this message]
2008-03-10 16:53 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080310165017.GA24812@lixom.net \
--to=olof@lixom.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=timur@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox