Bluetooth: fix passkey uninitialized when used
authorHoward Chung <howardchung@google.com>
Thu, 20 Feb 2020 03:17:29 +0000 (11:17 +0800)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 19 Feb 2020 19:35:46 +0000 (20:35 +0100)
This patch fix the issue: warning:variable 'passkey' is uninitialized
when used here

Link: https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU
Fixes: cee5f20fece3 ("Bluetooth: secure bluetooth stack from bluedump attack")
Reported-by: kbuild test robot <lkp@intel.com>
Suggested-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Howard Chung <howardchung@google.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/smp.c

index 50e0ac692ec4b61b44b846019dc55aecc49ab762..1476a91ce935725e06d4979d96fad1a6b036a811 100644 (file)
@@ -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;
                }
        }
 
@@ -2207,8 +2206,11 @@ mackey_and_ltk:
        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;