Commit 21870b52 authored by Johan Hedberg's avatar Johan Hedberg Committed by Gustavo Padovan

Bluetooth: Fix L2CAP error return used for failed channel lookups

The EFAULT error should only be used for memory address related errors
and ENOENT might be needed for other purposes than invalid CID errors.
This patch fixes the l2cap_config_req, l2cap_connect_create_rsp and
l2cap_create_channel_req handlers to use the unique EBADSLT error to
indicate failed lookups on a given CID.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent dc280801
...@@ -3884,13 +3884,13 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, ...@@ -3884,13 +3884,13 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
if (scid) { if (scid) {
chan = __l2cap_get_chan_by_scid(conn, scid); chan = __l2cap_get_chan_by_scid(conn, scid);
if (!chan) { if (!chan) {
err = -EFAULT; err = -EBADSLT;
goto unlock; goto unlock;
} }
} else { } else {
chan = __l2cap_get_chan_by_ident(conn, cmd->ident); chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
if (!chan) { if (!chan) {
err = -EFAULT; err = -EBADSLT;
goto unlock; goto unlock;
} }
} }
...@@ -3978,7 +3978,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, ...@@ -3978,7 +3978,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
chan = l2cap_get_chan_by_scid(conn, dcid); chan = l2cap_get_chan_by_scid(conn, dcid);
if (!chan) if (!chan)
return -ENOENT; return -EBADSLT;
if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) {
struct l2cap_cmd_rej_cid rej; struct l2cap_cmd_rej_cid rej;
...@@ -4438,7 +4438,7 @@ static int l2cap_create_channel_req(struct l2cap_conn *conn, ...@@ -4438,7 +4438,7 @@ static int l2cap_create_channel_req(struct l2cap_conn *conn,
hs_hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, conn->dst); hs_hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, conn->dst);
if (!hs_hcon) { if (!hs_hcon) {
hci_dev_put(hdev); hci_dev_put(hdev);
return -EFAULT; return -EBADSLT;
} }
BT_DBG("mgr %p bredr_chan %p hs_hcon %p", mgr, chan, hs_hcon); BT_DBG("mgr %p bredr_chan %p hs_hcon %p", mgr, chan, hs_hcon);
......
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