From: Johan Hedberg <johan.hedberg@gmail.com>
To: Simon Fels <simon.fels@canonical.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: bring device down when closing HCI_CHANNEL_USER socket
Date: Fri, 28 Aug 2015 14:16:05 +0300 [thread overview]
Message-ID: <20150828111605.GA30700@t440s.lan> (raw)
In-Reply-To: <1440759270-23099-2-git-send-email-simon.fels@canonical.com>
Hi Simon,
On Fri, Aug 28, 2015, Simon Fels wrote:
> When a HCI_CHANNEL_USER socket is open and should be closed we first
> try to close the device which will fail as hci_dev_close checks for
> HCI_CHANNEL_USER being set and if it is it just fails to close the
> device. Clearing the HCI_CHANNEL_USER flag first before trying to
> close the device fixes this.
>
> Signed-off-by: Simon Fels <simon.fels@canonical.com>
> ---
> backports/net/bluetooth/hci_sock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/backports/net/bluetooth/hci_sock.c b/backports/net/bluetooth/hci_sock.c
> index 9a2732f..c84c13e 100644
> --- a/backports/net/bluetooth/hci_sock.c
> +++ b/backports/net/bluetooth/hci_sock.c
> @@ -503,8 +503,8 @@ static int hci_sock_release(struct socket *sock)
>
> if (hdev) {
> if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
> - hci_dev_close(hdev->id);
> hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
> + hci_dev_close(hdev->id);
> mgmt_index_added(hdev);
> }
Thanks for catching this and coming up with a patch proposal!
My main concern is that there's code within the hci_dev_close() path
that assumes HCI_USER_CHANNEL may be set. E.g. this in
hci_dev_do_close() (which hci_dev_close calls):
if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
!hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
test_bit(HCI_UP, &hdev->flags)) {
/* Execute vendor specific shutdown routine */
if (hdev->shutdown)
hdev->shutdown(hdev);
}
With your change the hdev->shutdown() callback would get called which
seems to be what the above if-statement tries to protect against.
Johan
next prev parent reply other threads:[~2015-08-28 11:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 10:54 Closing HCI_CHANNEL_USER socket doesn't close HCI device Simon Fels
2015-08-28 10:54 ` [PATCH] Bluetooth: bring device down when closing HCI_CHANNEL_USER socket Simon Fels
2015-08-28 11:16 ` Johan Hedberg [this message]
2015-08-28 15:58 ` 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=20150828111605.GA30700@t440s.lan \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=simon.fels@canonical.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;
as well as URLs for NNTP newsgroup(s).