From: Felipe Balbi <balbi@ti.com>
To: Chuansheng Liu <chuansheng.liu@intel.com>
Cc: <balbi@ti.com>, <gregkh@linuxfoundation.org>, <mina86@mina86.com>,
<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>
Subject: Re: [PATCH] usb: gadget: return the right length in ffs_epfile_io()
Date: Mon, 3 Mar 2014 10:30:13 -0600 [thread overview]
Message-ID: <20140303163013.GC2759@saruman.home> (raw)
In-Reply-To: <1393483771-24623-1-git-send-email-chuansheng.liu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]
Hi,
On Thu, Feb 27, 2014 at 02:49:31PM +0800, Chuansheng Liu 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>
> ---
> 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;
> + }
please rebase on my "testing/next" branch
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-03-03 16:31 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
2014-02-27 23:45 ` David Cohen
2014-03-03 16:30 ` Felipe Balbi [this message]
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=20140303163013.GC2759@saruman.home \
--to=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=mina86@mina86.com \
--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