All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Jaganath Kanakkassery <jaganath.k@samsung.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2 2/2] Bluetooth: Override status if local user rejects pairing
Date: Fri, 6 Jul 2012 12:25:10 +0300	[thread overview]
Message-ID: <20120706092510.GB10494@x220.ger.corp.intel.com> (raw)
In-Reply-To: <1341551602-1493-2-git-send-email-jaganath.k@samsung.com>

Hi Jaganath,

On Fri, Jul 06, 2012, Jaganath Kanakkassery wrote:
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 5a442b9..4fc3379 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1764,6 +1764,10 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status)
>  	bacpy(&rp.addr.bdaddr, &conn->dst);
>  	rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type);
>  
> +	/* Override status if local device rejected pairing */
> +	if (conn->auth_rejected == true)
> +		status = MGMT_STATUS_REJECTED;

I think simply "if (conn->auth_rejected)" should be fine (no "== true").
And what if status == 0 and this is a repairing over the same hci_conn
which was previously rejected? Seems like you'd give a false negative in
that case. Maybe the check should be "if (status && conn->auth_rejected)".

> +	/* Override status if local device rejected pairing */
> +	if (auth_rejected == true)

Same thing again with the comparison. The stuff inside () of an
if-statement should be a valid boolean, and if the standard bool type by
itself can't be considered that then I don't know what can.

The thing that's worrying me is that there's nowhere where you clear
conn->auth_rejected. If a re-authentication is attempted with the same
hci_conn the code would be doing wrong things. I'm not completely sure
where this clearing should occur since we're potentially sending two
mgmt events through two different code paths (pairing_complete and
mgmt_auth_failed) so clearing in either one might be risky in that it
causes the second function to do the wrong thing.

Johan

  reply	other threads:[~2012-07-06  9:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06  5:13 [PATCH v2 1/2] Bluetooth: Refactor PIN code rejection to use user_pairing_resp() Jaganath Kanakkassery
2012-07-06  5:13 ` [PATCH v2 2/2] Bluetooth: Override status if local user rejects pairing Jaganath Kanakkassery
2012-07-06  9:25   ` Johan Hedberg [this message]
2012-07-07 13:07     ` Jaganath
2012-07-10 18:26       ` Johan Hedberg
2012-07-06  9:18 ` [PATCH v2 1/2] Bluetooth: Refactor PIN code rejection to use user_pairing_resp() Johan Hedberg
2012-07-07 13:07   ` Jaganath

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=20120706092510.GB10494@x220.ger.corp.intel.com \
    --to=johan.hedberg@gmail.com \
    --cc=jaganath.k@samsung.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 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.