From: Michal Nazarewicz <mina86@mina86.com>
To: Chuansheng Liu <chuansheng.liu@intel.com>,
balbi@ti.com, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
david.a.cohen@intel.com, jin.can.zhuang@intel.com,
yu.y.wang@intel.com, Chuansheng Liu <chuansheng.liu@intel.com>
Subject: Re: [PATCH] usb: gadget: return the right length in ffs_epfile_io()
Date: Thu, 27 Feb 2014 13:15:25 +0100 [thread overview]
Message-ID: <xa1teh2o4uqq.fsf@mina86.com> (raw)
In-Reply-To: <1393483771-24623-1-git-send-email-chuansheng.liu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
On Thu, Feb 27 2014, Chuansheng Liu <chuansheng.liu@intel.com> wrote:
> When the request length is aligned to maxpacketsize, sometimes
> the return length ret > the user space requested len.
>
> At that time, we will use min_t(size_t, ret, len) to limit the
> size in case of user data buffer overflow.
>
> But we need return the min_t(size_t, ret, len) to tell the user
> space rightly also.
>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> drivers/usb/gadget/f_fs.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
> index 2b43343..31ee7af 100644
> --- a/drivers/usb/gadget/f_fs.c
> +++ b/drivers/usb/gadget/f_fs.c
> @@ -687,10 +687,12 @@ static ssize_t ffs_epfile_io(struct file *file,
> * space for.
> */
> ret = ep->status;
> - if (read && ret > 0 &&
> - unlikely(copy_to_user(buf, data,
> - min_t(size_t, ret, len))))
> - ret = -EFAULT;
> + if (read && ret > 0) {
> + ret = min_t(size_t, ret, len);
> +
> + if (unlikely(copy_to_user(buf, data, ret)))
> + ret = -EFAULT;
> + }
> }
> }
>
> --
> 1.9.rc0
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2014-02-27 12:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 6:49 Chuansheng Liu
2014-02-27 12:15 ` Michal Nazarewicz [this message]
2014-02-27 23:45 ` David Cohen
2014-03-03 16:30 ` Felipe Balbi
2014-03-04 7:47 ` Liu, Chuansheng
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=xa1teh2o4uqq.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=balbi@ti.com \
--cc=chuansheng.liu@intel.com \
--cc=david.a.cohen@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jin.can.zhuang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=yu.y.wang@intel.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
Powered by JetHome