From: "Michał Nazarewicz" <m.nazarewicz@samsung.com>
To: Michal Nazarewicz <m.nazarewicz@samsung.com>, linux-usb@vger.kernel.org
Cc: Peter Korsgaard <jacmet@sunsite.dk>,
Rupesh Gujare <rupeshgujare@gmail.com>,
linux-kernel@vger.kernel.org,
David Brownell <dbrownell@users.sourceforge.net>,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 3/8] USB: f_fs: the FunctionFS driver
Date: Wed, 07 Apr 2010 19:11:12 +0200 [thread overview]
Message-ID: <op.vasx0y1d7p4s8u@pikus> (raw)
In-Reply-To: <d8e956ce78914750460877b87ba2b0f707ab8a0f.1270644740.git.mina86@mina86.com>
On Wed, 07 Apr 2010 15:41:30 +0200, Michal Nazarewicz <m.nazarewicz@samsung.com> wrote:
> +static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf,
> + size_t n)
> +{
> + /* We are holding ffs->ev.waitq.lock and ffs->mutex and we need
> + * to release them. */
> +
> + struct usb_functionfs_event events[n];
> + unsigned i = 0;
> +
> + memset(events, 0, sizeof events);
> +
> + do {
> + events[i].type = ffs->ev.types[i];
> + if (events[i].type == FUNCTIONFS_SETUP) {
> + events[i].u.setup = ffs->ev.setup;
> + ffs->setup_state = FFS_SETUP_PENDING;
> + }
> + } while (++i < n);
> +
> + ffs->ev.count = 0;
I've just noticed. This line should instead read:
+ if (n < ffs->ev.count) {
+ ffs->ev.count -= n;
+ memmove(ffs->ev.types, ffs->ev.types + n,
+ ffs->ev.count * sizeof *ffs->ev.types);
+ } else {
+ ffs->ev.count = 0;
+ }
This is a minor bug which should be rather hard to observe (and only
if user-space reads() less then 4 * sizeof(struct usb_functionfs_event)
bytes when reading from "ep0") so posted code is good for testing.
(I'll post a fixed version later on with possibly other fixes and
changes.)
> +
> + spin_unlock_irq(&ffs->ev.waitq.lock);
> + mutex_unlock(&ffs->mutex);
> +
> + return unlikely(__copy_to_user(buf, events, sizeof events))
> + ? -EFAULT : sizeof events;
> +}
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał "mina86" Nazarewicz (o o)
ooo +---[mina86@mina86.com]---[mina86@jabber.org]---ooO--(_)--Ooo--
next prev parent reply other threads:[~2010-04-07 17:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-07 13:41 [PATCH 0/7] The FunctionFS composite function Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 1/8] USB: composite: allow optional removal of __init and __exit tags Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 2/8] sched: __wake_up_locked() exported Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 3/8] USB: f_fs: the FunctionFS driver Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 4/8] USB: Ethernet: allow optional removal of __init and __init_data tags Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 5/8] USB: g_ffs: the FunctionFS gadget driver Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 6/8] USB: ffs-test: FunctionFS testing program Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 7/8] USB: testusb: imported David Brownell's USB testing application Michal Nazarewicz
2010-04-07 13:41 ` [PATCH 8/8] USB: testusb: testusb compatibility with FunctionFS gadget Michal Nazarewicz
2010-04-08 0:30 ` Greg KH
2010-04-08 0:29 ` [PATCH 7/8] USB: testusb: imported David Brownell's USB testing application Greg KH
2010-04-14 9:30 ` David Brownell
2010-04-14 16:46 ` Greg KH
2010-04-14 16:47 ` Greg KH
2010-04-08 6:10 ` Heikki Krogerus
2010-04-08 6:18 ` Greg KH
2010-04-08 6:34 ` Heikki Krogerus
2010-04-14 9:41 ` David Brownell
2010-04-14 12:50 ` Michał Nazarewicz
2010-04-14 16:47 ` Greg KH
2010-04-07 17:11 ` Michał Nazarewicz [this message]
2010-04-07 15:29 ` [PATCH 2/8] sched: __wake_up_locked() exported Greg KH
2010-04-07 17:11 ` Michał Nazarewicz
2010-04-08 0:28 ` Greg KH
2010-04-07 15:28 ` [PATCH 1/8] USB: composite: allow optional removal of __init and __exit tags Greg KH
2010-04-07 15:39 ` Michał Nazarewicz
2010-04-08 0:26 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2010-04-09 19:21 [PATCH 0/7] The FunctionFS composite function Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 1/8] wait_event_interruptible_locked() interface Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 2/8] fs/timerfd.c: make use of wait_event_interruptible_locked_irq() Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 3/8] USB: gadget: __init and __exit tags removed Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 4/8] USB: f_fs: the FunctionFS driver Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 5/8] USB: g_ffs: the FunctionFS gadget driver Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 6/8] USB: ffs-test: FunctionFS testing program Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 7/8] USB: testusb: an USB testing application Michal Nazarewicz
2010-04-09 19:21 ` [PATCHv2 8/8] USB: testusb: testusb compatibility with FunctionFS gadget Michal Nazarewicz
2010-04-10 22:51 ` [PATCHv2 7/8] USB: testusb: an USB testing application David Brownell
2010-04-29 22:15 ` [PATCHv2 3/8] USB: gadget: __init and __exit tags removed Greg KH
2010-04-29 23:02 ` Michal Nazarewicz
2010-04-29 23:22 ` Greg KH
2010-04-30 5:41 ` Michal Nazarewicz
2010-04-11 14:31 ` [PATCHv2 2/8] fs/timerfd.c: make use of wait_event_interruptible_locked_irq() Thomas Gleixner
2010-04-11 19:16 ` Michal Nazarewicz
2010-04-11 15:02 ` [PATCHv2 1/8] wait_event_interruptible_locked() interface Thomas Gleixner
2010-04-11 19:27 ` Michal Nazarewicz
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=op.vasx0y1d7p4s8u@pikus \
--to=m.nazarewicz@samsung.com \
--cc=dbrownell@users.sourceforge.net \
--cc=jacmet@sunsite.dk \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=rupeshgujare@gmail.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