Commit d1d900f8 authored by Guenter Roeck's avatar Guenter Roeck Committed by Marcel Holtmann

Bluetooth: Simplify / fix return values from tk_request

Some static checker run by 0day reports a variableScope warning.

net/bluetooth/smp.c:870:6: warning:
	The scope of the variable 'err' can be reduced. [variableScope]

There is no need for two separate variables holding return values.
Stick with the existing variable. While at it, don't pre-initialize
'ret' because it is set in each code path.

tk_request() is supposed to return a negative error code on errors,
not a bluetooth return code. The calling code converts the return
value to SMP_UNSPECIFIED if needed.

Fixes: 92516cd9 ("Bluetooth: Always request for user confirmation for Just Works")
Cc: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent c2aa30db
...@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, ...@@ -854,8 +854,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
struct l2cap_chan *chan = conn->smp; struct l2cap_chan *chan = conn->smp;
struct smp_chan *smp = chan->data; struct smp_chan *smp = chan->data;
u32 passkey = 0; u32 passkey = 0;
int ret = 0; int ret;
int err;
/* Initialize key for JUST WORKS */ /* Initialize key for JUST WORKS */
memset(smp->tk, 0, sizeof(smp->tk)); memset(smp->tk, 0, sizeof(smp->tk));
...@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, ...@@ -887,12 +886,12 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
/* If Just Works, Continue with Zero TK and ask user-space for /* If Just Works, Continue with Zero TK and ask user-space for
* confirmation */ * confirmation */
if (smp->method == JUST_WORKS) { if (smp->method == JUST_WORKS) {
err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
hcon->type, hcon->type,
hcon->dst_type, hcon->dst_type,
passkey, 1); passkey, 1);
if (err) if (ret)
return SMP_UNSPECIFIED; return ret;
set_bit(SMP_FLAG_WAIT_USER, &smp->flags); set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment