Bluetooth: Refuse ConfigRsp with different mode
authorGustavo F. Padovan <padovan@profusion.mobi>
Tue, 8 Jun 2010 23:08:49 +0000 (20:08 -0300)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 21 Jul 2010 17:39:08 +0000 (10:39 -0700)
If our mode is Basic Mode we have to refuse any ConfigRsp that proposes
a different mode.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/l2cap.c

index ca9bab2257776084a8e966afd3facb632c11e8b0..c5904082392c26659d82d10b09d00cce430c0107 100644 (file)
@@ -2747,7 +2747,6 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data,
                                                        rfc.mode != pi->mode)
                                return -ECONNREFUSED;
 
-                       pi->mode = rfc.mode;
                        pi->fcs = 0;
 
                        l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC,
@@ -2756,6 +2755,11 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data,
                }
        }
 
+       if (pi->mode == L2CAP_MODE_BASIC && pi->mode != rfc.mode)
+               return -ECONNREFUSED;
+
+       pi->mode = rfc.mode;
+
        if (*result == L2CAP_CONF_SUCCESS) {
                switch (rfc.mode) {
                case L2CAP_MODE_ERTM: