From: Felipe Balbi <balbi@kernel.org>
To: "Felipe F. Tonello" <eu@felipetonello.com>, linux-usb@vger.kernel.org
Cc: "# v4 . 4+" <stable@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: f_midi: added spinlock on transmit function
Date: Wed, 09 Mar 2016 09:08:25 +0200 [thread overview]
Message-ID: <877fhcgmc6.fsf@intel.com> (raw)
In-Reply-To: <1457468507-25622-1-git-send-email-eu@felipetonello.com>
[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]
Hi,
"Felipe F. Tonello" <eu@felipetonello.com> writes:
> [ text/plain ]
> Since f_midi_transmit is called by both ALSA and USB sub-systems, it can
> potentially cause a race condition between both calls because f_midi_transmit
> is not reentrant nor thread-safe. This is due to an implementation detail that
> the transmit function looks for the next available usb request from the fifo
> and only enqueues it if there is data to send, otherwise just re-uses it. So,
> if both ALSA and USB frameworks calls this function at the same time,
> kfifo_seek() will return the same usb_request, which will cause a race
> condition.
>
> To solve this problem a syncronization mechanism is necessary. In this case it
> is used a spinlock since f_midi_transmit is also called by usb_request->complete
> callback in interrupt context.
>
> Cc: <stable@vger.kernel.org> # v4.4+
> Fixes: e1e3d7ec5da3 ("usb: gadget: f_midi: pre-allocate IN requests")
> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
> Tested-by: Felipe F. Tonello <eu@felipetonello.com>
adding one's own Tested-by is a bit redundant. I'll remove it while
applying ;-)
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2016-03-09 7:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 20:21 [PATCH] usb: gadget: f_midi: added spinlock on transmit function Felipe F. Tonello
2016-03-09 7:08 ` Felipe Balbi [this message]
2016-03-09 7:20 ` Felipe Balbi
2016-03-09 9:35 ` Felipe Ferreri Tonello
2016-03-09 10:33 ` Felipe Balbi
2016-03-09 16:15 ` Felipe Ferreri Tonello
-- strict thread matches above, loose matches on Subject: below --
2016-03-09 16:17 Felipe F. Tonello
2016-03-09 16:58 ` Felipe Ferreri Tonello
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=877fhcgmc6.fsf@intel.com \
--to=balbi@kernel.org \
--cc=eu@felipetonello.com \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.