linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v5 04/15] Bluetooth: Check pending commands in stop_discovery()
Date: Sat, 15 Oct 2011 11:33:04 -0700	[thread overview]
Message-ID: <1318703615.15441.68.camel@aeonflux> (raw)
In-Reply-To: <1317856847-28167-5-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch adds extra checks in stop_discovery().
> 
> The MGMT_OP_STOP_DISCOVERY command should be executed if the device
> is running the discovery procedure. So, if there is no discovery
> procedure running then EINVAL command status should be returned.
> 
> Also, if a MGMT_OP_STOP_DISCOVERY command has been already issued
> then EINPROGRESS command status should returned.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
>  net/bluetooth/mgmt.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index d8333e0..5e1414b 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1664,6 +1664,17 @@ static int stop_discovery(struct sock *sk, u16 index)
>  
>  	hci_dev_lock_bh(hdev);
>  
> +	if (!mgmt_pending_find(MGMT_OP_START_DISCOVERY, index)) {
> +		err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, EINVAL);
> +		goto failed;
> +	}
> +
> +	if (mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index)) {
> +		err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY,
> +								EINPROGRESS);
> +		goto failed;
> +	}
> +

and this case makes it obvious clear that we should use a flag to keep
track of the current discovery state. You are running through the same
list twice in a row. This is utterly stupid.

Regards

Marcel



  reply	other threads:[~2011-10-15 18:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05 23:20 [PATCH v5 00/15] Discovery procedure support Andre Guedes
2011-10-05 23:20 ` [PATCH v5 01/15] Bluetooth: Periodic Inquiry and mgmt discovering event Andre Guedes
2011-10-05 23:20 ` [PATCH v5 02/15] Bluetooth: Add mgmt_discovery_complete() Andre Guedes
2011-10-05 23:20 ` [PATCH v5 03/15] Bluetooth: Check pending command in start_discovery() Andre Guedes
2011-10-15 18:30   ` Marcel Holtmann
2011-10-17 12:59     ` Andre Guedes
2011-10-05 23:20 ` [PATCH v5 04/15] Bluetooth: Check pending commands in stop_discovery() Andre Guedes
2011-10-15 18:33   ` Marcel Holtmann [this message]
2011-10-05 23:20 ` [PATCH v5 05/15] Bluetooth: Create hci_do_inquiry() Andre Guedes
2011-10-05 23:20 ` [PATCH v5 06/15] Bluetooth: Create hci_cancel_inquiry() Andre Guedes
2011-10-05 23:20 ` [PATCH v5 07/15] Bluetooth: Handle race condition in Discovery Andre Guedes
2011-10-05 23:20 ` [PATCH v5 08/15] Bluetooth: Prepare for full support discovery procedures Andre Guedes
2011-10-06 18:50   ` Gustavo Padovan
2011-10-06 20:30     ` Andre Guedes
2011-10-07 19:51       ` Gustavo Padovan
2011-10-10 16:47         ` Andre Guedes
2011-10-05 23:20 ` [PATCH v5 09/15] Bluetooth: Send mgmt_discovering events Andre Guedes
2011-10-05 23:20 ` [PATCH v5 10/15] Bluetooth: Add 'eir_len' param to mgmt_device_found() Andre Guedes
2011-10-05 23:20 ` [PATCH v5 11/15] Bluetooth: Report LE devices Andre Guedes
2011-10-05 23:20 ` [PATCH v5 12/15] Bluetooth: Add LE Set Scan Parameter Command Andre Guedes
2011-10-05 23:20 ` [PATCH v5 13/15] Bluetooth: LE scan infra-structure Andre Guedes
2011-10-06 19:06   ` Gustavo Padovan
2011-10-06 20:31     ` Andre Guedes
2011-10-07 20:12       ` Gustavo Padovan
2011-10-07 20:31         ` Johan Hedberg
2011-10-10 16:48         ` Andre Guedes
2011-10-15 18:18           ` Marcel Holtmann
2011-10-17 12:50             ` Andre Guedes
2011-10-05 23:20 ` [PATCH v5 14/15] Bluetooth: Support LE-Only discovery procedure Andre Guedes
2011-10-05 23:20 ` [PATCH v5 15/15] Bluetooth: Support BR/EDR/LE " Andre Guedes

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=1318703615.15441.68.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=andre.guedes@openbossa.org \
    --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).