Bluetooth: Fix false-positive "uninitialized" compiler warning
Some gcc versions don't seem to be able to properly track the flow of the smp_cmd_pairing_random() function and end up causing the following types of (false-positive) warnings: smp.c:1995:6: warning: ‘nb’ may be used uninitialized in this function [-Wmaybe-uninitialized] err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); smp.c:1995:6: warning: ‘na’ may be used uninitialized in this function [-Wmaybe-uninitialized] err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); ^ smp.c:1995:6: warning: ‘pkbx’ may be used uninitialized in this function [-Wmaybe-uninitialized] err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); ^ smp.c:1995:6: warning: ‘pkax’ may be used uninitialized in this function [-Wmaybe-uninitialized] err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); This patch fixes the issue by moving the pkax/pkbx and na/nb initialization earlier in the function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
7f376cd6dc
commit
580039e838
1 changed files with 12 additions and 10 deletions
|
@ -1947,6 +1947,18 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
|
||||||
if (!test_bit(SMP_FLAG_SC, &smp->flags))
|
if (!test_bit(SMP_FLAG_SC, &smp->flags))
|
||||||
return smp_random(smp);
|
return smp_random(smp);
|
||||||
|
|
||||||
|
if (hcon->out) {
|
||||||
|
pkax = smp->local_pk;
|
||||||
|
pkbx = smp->remote_pk;
|
||||||
|
na = smp->prnd;
|
||||||
|
nb = smp->rrnd;
|
||||||
|
} else {
|
||||||
|
pkax = smp->remote_pk;
|
||||||
|
pkbx = smp->local_pk;
|
||||||
|
na = smp->rrnd;
|
||||||
|
nb = smp->prnd;
|
||||||
|
}
|
||||||
|
|
||||||
if (smp->method == REQ_OOB) {
|
if (smp->method == REQ_OOB) {
|
||||||
if (!hcon->out)
|
if (!hcon->out)
|
||||||
smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM,
|
smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM,
|
||||||
|
@ -1969,20 +1981,10 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
|
||||||
|
|
||||||
if (memcmp(smp->pcnf, cfm, 16))
|
if (memcmp(smp->pcnf, cfm, 16))
|
||||||
return SMP_CONFIRM_FAILED;
|
return SMP_CONFIRM_FAILED;
|
||||||
|
|
||||||
pkax = smp->local_pk;
|
|
||||||
pkbx = smp->remote_pk;
|
|
||||||
na = smp->prnd;
|
|
||||||
nb = smp->rrnd;
|
|
||||||
} else {
|
} else {
|
||||||
smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
|
smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
|
||||||
smp->prnd);
|
smp->prnd);
|
||||||
SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK);
|
SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK);
|
||||||
|
|
||||||
pkax = smp->remote_pk;
|
|
||||||
pkbx = smp->local_pk;
|
|
||||||
na = smp->rrnd;
|
|
||||||
nb = smp->prnd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mackey_and_ltk:
|
mackey_and_ltk:
|
||||||
|
|
Loading…
Add table
Reference in a new issue