From: Johan Hedberg <johan.hedberg@gmail.com>
To: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 3/3] Bluetooth: Add missing hci_dev locking when calling mgmt functions
Date: Wed, 9 Nov 2011 00:26:10 +0200 [thread overview]
Message-ID: <20111108222610.GA17415@fusion.localdomain> (raw)
In-Reply-To: <CAMXE1-qLHUj_QzkuyT9NQmj+DBVvWLD_djoXG4x_FyVast=_SQ@mail.gmail.com>
Hi Andrei,
On Tue, Nov 08, 2011, Andrei Emeltchenko wrote:
> > --- a/net/bluetooth/hci_core.c
> > +++ b/net/bluetooth/hci_core.c
> > @@ -549,8 +549,11 @@ int hci_dev_open(__u16 dev)
> > hci_dev_hold(hdev);
> > set_bit(HCI_UP, &hdev->flags);
> > hci_notify(hdev, HCI_DEV_UP);
> > - if (!test_bit(HCI_SETUP, &hdev->flags))
> > + if (!test_bit(HCI_SETUP, &hdev->flags)) {
> > + hci_dev_lock_bh(hdev);
> > mgmt_powered(hdev, 1);
> > + hci_dev_unlock_bh(hdev);
>
> Shall we acquire lock before test_bit here and below?
Once the HCI_SETUP flag has been cleared it never gets set again for a
hci_dev, so in the above case it doesn't really make a difference
whether we lock before or after the test.
> > @@ -1561,8 +1566,11 @@ void hci_unregister_dev(struct hci_dev *hdev)
> > kfree_skb(hdev->reassembly[i]);
> >
> > if (!test_bit(HCI_INIT, &hdev->flags) &&
> > - !test_bit(HCI_SETUP, &hdev->flags))
> > + !test_bit(HCI_SETUP, &hdev->flags)) {
> > + hci_dev_lock_bh(hdev);
> > mgmt_index_removed(hdev);
> > + hci_dev_unlock_bh(hdev);
> > + }
The same applies for the above. The only question there is about
HCI_INIT. Since we're inside hci_unregister_dev and have already called
hci_dev_do_close I don't think there's any problem here. Furthermore,
the whole test for HCI_INIT looks unnecessary to me since testing for
HCI_SETUP should be enough. I might send a separate patch for that later
(it's anyway unrelated to this locking patch).
Johan
next prev parent reply other threads:[~2011-11-08 22:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 18:40 [PATCH 1/3] Bluetooth: Pass full hci_dev struct to mgmt callbacks johan.hedberg
2011-11-08 18:40 ` [PATCH 2/3] Bluetooth: Move pending management command list into struct hci_dev johan.hedberg
2011-11-09 7:35 ` Marcel Holtmann
2011-11-08 18:40 ` [PATCH 3/3] Bluetooth: Add missing hci_dev locking when calling mgmt functions johan.hedberg
2011-11-08 21:30 ` Andrei Emeltchenko
2011-11-08 22:26 ` Johan Hedberg [this message]
2011-11-09 7:36 ` Marcel Holtmann
2011-11-09 14:34 ` Gustavo Padovan
2011-11-09 7:34 ` [PATCH 1/3] Bluetooth: Pass full hci_dev struct to mgmt callbacks Marcel Holtmann
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=20111108222610.GA17415@fusion.localdomain \
--to=johan.hedberg@gmail.com \
--cc=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).