* [Bluez PATCH v2] bluetooth: fix passkey uninitialized when used
@ 2020-02-19 6:45 Howard Chung
2020-02-19 19:21 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Howard Chung @ 2020-02-19 6:45 UTC (permalink / raw)
To: linux-bluetooth, marcel
Cc: chromeos-bluetooth-upstreaming, Howard Chung, David S. Miller,
Johan Hedberg, netdev, linux-kernel, Jakub Kicinski,
clang-built-linux
This issue cause a warning here
https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU
Signed-off-by: Howard Chung <howardchung@google.com>
---
Changes in v2:
- refactor code
net/bluetooth/smp.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 50e0ac692ec4..929e0bebaf80 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2115,7 +2115,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
struct l2cap_chan *chan = conn->smp;
struct smp_chan *smp = chan->data;
struct hci_conn *hcon = conn->hcon;
- u8 *pkax, *pkbx, *na, *nb;
+ u8 *pkax, *pkbx, *na, *nb, confirm_hint;
u32 passkey;
int err;
@@ -2179,13 +2179,12 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
*/
if (hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
hcon->role)) {
- err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
- hcon->type,
- hcon->dst_type,
- passkey, 1);
- if (err)
- return SMP_UNSPECIFIED;
- set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
+ /* Set passkey to 0. The value can be any number since
+ * it'll be ignored anyway.
+ */
+ passkey = 0;
+ confirm_hint = 1;
+ goto confirm;
}
}
@@ -2206,9 +2205,11 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);
if (err)
return SMP_UNSPECIFIED;
+ confirm_hint = 0;
+confirm:
err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type,
- hcon->dst_type, passkey, 0);
+ hcon->dst_type, passkey, confirm_hint);
if (err)
return SMP_UNSPECIFIED;
--
2.25.0.265.gbab2e86ba0-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Bluez PATCH v2] bluetooth: fix passkey uninitialized when used
2020-02-19 6:45 [Bluez PATCH v2] bluetooth: fix passkey uninitialized when used Howard Chung
@ 2020-02-19 19:21 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2020-02-19 19:21 UTC (permalink / raw)
To: Howard Chung
Cc: linux-bluetooth, Marcel Holtmann, chromeos-bluetooth-upstreaming,
David S. Miller, Johan Hedberg, Network Development, LKML,
Jakub Kicinski, clang-built-linux
On Tue, Feb 18, 2020 at 10:45 PM 'Howard Chung' via Clang Built Linux
<clang-built-linux@googlegroups.com> wrote:
>
> This issue cause a warning here
> https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU
>
> Signed-off-by: Howard Chung <howardchung@google.com>
It can be helpful to just include the text from the warning in the
commit message, for future patches, then a "Link" tag (below) to the
report. Also,if you use Marcel's suggestions, it's polite to add a
`Suggested-by` tag.
Link: https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU
Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
>
> ---
>
> Changes in v2:
> - refactor code
>
> net/bluetooth/smp.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
> index 50e0ac692ec4..929e0bebaf80 100644
> --- a/net/bluetooth/smp.c
> +++ b/net/bluetooth/smp.c
> @@ -2115,7 +2115,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
> struct l2cap_chan *chan = conn->smp;
> struct smp_chan *smp = chan->data;
> struct hci_conn *hcon = conn->hcon;
> - u8 *pkax, *pkbx, *na, *nb;
> + u8 *pkax, *pkbx, *na, *nb, confirm_hint;
> u32 passkey;
> int err;
>
> @@ -2179,13 +2179,12 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
> */
> if (hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
> hcon->role)) {
> - err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
> - hcon->type,
> - hcon->dst_type,
> - passkey, 1);
> - if (err)
> - return SMP_UNSPECIFIED;
> - set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
> + /* Set passkey to 0. The value can be any number since
> + * it'll be ignored anyway.
> + */
> + passkey = 0;
> + confirm_hint = 1;
> + goto confirm;
> }
> }
>
> @@ -2206,9 +2205,11 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
> err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);
> if (err)
> return SMP_UNSPECIFIED;
> + confirm_hint = 0;
>
> +confirm:
> err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type,
> - hcon->dst_type, passkey, 0);
> + hcon->dst_type, passkey, confirm_hint);
> if (err)
> return SMP_UNSPECIFIED;
>
> --
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-19 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 6:45 [Bluez PATCH v2] bluetooth: fix passkey uninitialized when used Howard Chung
2020-02-19 19:21 ` Nick Desaulniers
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).