From: Marcel Holtmann <marcel@holtmann.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: Linux Bluetooth <linux-bluetooth@vger.kernel.org>,
"Gustavo F. Padovan" <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Jiri Slaby <jslaby@suse.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: vhci: Fix race at creating hci device
Date: Wed, 20 Apr 2016 16:32:24 +0200 [thread overview]
Message-ID: <4C452D10-6A16-47B1-9DF2-E1B8D162F5B7@holtmann.org> (raw)
In-Reply-To: <1460647939-15637-1-git-send-email-tiwai@suse.de>
Hi Takashi,
> hci_vhci driver creates a hci device object dynamically upon each
> HCI_VENDOR_PKT write. Although it checks the already created object
> and returns an error, it's still racy and may build multiple hci_dev
> objects concurrently when parallel writes are performed, as the device
> tracks only a single hci_dev object.
>
> This patch introduces a mutex to protect against the concurrent device
> creations.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> drivers/bluetooth/hci_vhci.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
> index f67ea1c090cb..39230f30f544 100644
> --- a/drivers/bluetooth/hci_vhci.c
> +++ b/drivers/bluetooth/hci_vhci.c
> @@ -50,6 +50,7 @@ struct vhci_data {
> wait_queue_head_t read_wait;
> struct sk_buff_head readq;
>
> + struct mutex open_mutex;
> struct delayed_work open_timeout;
> };
>
> @@ -87,7 +88,7 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
> return 0;
> }
>
> -static int vhci_create_device(struct vhci_data *data, __u8 opcode)
> +static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
> {
> struct hci_dev *hdev;
> struct sk_buff *skb;
> @@ -151,6 +152,19 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
> return 0;
> }
>
> +static int vhci_create_device(struct vhci_data *data, __u8 opcode)
> +{
> + int err;
> +
> + mutex_lock(&data->open_mutex);
> + if (data->hdev)
> + err = -EBADFD;
I moved this check into __vhci_create_device after applying your patch to bluetooth-next tree. I think that is a lot cleaner and no need for you to respin it.
Regards
Marcel
next prev parent reply other threads:[~2016-04-20 14:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 15:32 [PATCH] Bluetooth: vhci: Fix race at creating hci device Takashi Iwai
2016-04-20 13:16 ` Marcel Holtmann
2016-04-20 13:35 ` Takashi Iwai
2016-04-20 14:32 ` Marcel Holtmann [this message]
2016-04-20 14:55 ` Takashi Iwai
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=4C452D10-6A16-47B1-9DF2-E1B8D162F5B7@holtmann.org \
--to=marcel@holtmann.org \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=jslaby@suse.cz \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.de \
/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.