Bluetooth: Add return check for L2CAP security level set
authorFugang Duan <fugang.duan@nxp.com>
Fri, 15 Mar 2019 03:17:28 +0000 (03:17 +0000)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 23 Apr 2019 16:09:07 +0000 (18:09 +0200)
Add return check for security level set for socket interface since
stack will check the return value.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/l2cap_sock.c

index dcb14abebeba31d5fcd860dd5279d35990532262..a7be8b59b3c280de738ec808534635265ee35169 100644 (file)
@@ -791,10 +791,13 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
 
                conn = chan->conn;
 
-               /*change security for LE channels */
+               /* change security for LE channels */
                if (chan->scid == L2CAP_CID_ATT) {
-                       if (smp_conn_security(conn->hcon, sec.level))
+                       if (smp_conn_security(conn->hcon, sec.level)) {
+                               err = -EINVAL;
                                break;
+                       }
+
                        set_bit(FLAG_PENDING_SECURITY, &chan->flags);
                        sk->sk_state = BT_CONFIG;
                        chan->state = BT_CONFIG;