diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-10-05 09:56:54 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-10-07 18:15:11 -0400 |
commit | 85e34368dea6fc8a2d16464e01c85d3b7bd682bd (patch) | |
tree | 162bc38530ab077e3d73dff6293b814108cff17f | |
parent | 079db0c6e3854b3af9808268f3b884fa48ed0034 (diff) |
Bluetooth: Fix dereference after NULL check
Move code dereferencing possible NULL pointer to the check branch.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 2542abd3336f..a71c4089d175 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -382,13 +382,14 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
382 | } | 382 | } |
383 | 383 | ||
384 | memset(&sec, 0, sizeof(sec)); | 384 | memset(&sec, 0, sizeof(sec)); |
385 | if (chan->conn) | 385 | if (chan->conn) { |
386 | sec.level = chan->conn->hcon->sec_level; | 386 | sec.level = chan->conn->hcon->sec_level; |
387 | else | ||
388 | sec.level = chan->sec_level; | ||
389 | 387 | ||
390 | if (sk->sk_state == BT_CONNECTED) | 388 | if (sk->sk_state == BT_CONNECTED) |
391 | sec.key_size = chan->conn->hcon->enc_key_size; | 389 | sec.key_size = chan->conn->hcon->enc_key_size; |
390 | } else { | ||
391 | sec.level = chan->sec_level; | ||
392 | } | ||
392 | 393 | ||
393 | len = min_t(unsigned int, len, sizeof(sec)); | 394 | len = min_t(unsigned int, len, sizeof(sec)); |
394 | if (copy_to_user(optval, (char *) &sec, len)) | 395 | if (copy_to_user(optval, (char *) &sec, len)) |