diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-08-17 16:28:57 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 13:07:53 -0400 |
commit | f8aaf9b65a77267f749c1af641e46c3457d50701 (patch) | |
tree | de1e0c30c71feca081078fe6a23daa5703759d94 /net/bluetooth/mgmt.c | |
parent | 51bb8457ddfa74ede52bf8c02054dea831d59fff (diff) |
Bluetooth: Fix using hci_conn_get() for hci_conn pointers
Wherever we keep hci_conn pointers around we should be using
hci_conn_get/put to ensure that they stay valid. This patch fixes
all places violating against the principle currently.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c2457435a670..d8c66663ade8 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -3063,6 +3063,7 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) | |||
3063 | conn->disconn_cfm_cb = NULL; | 3063 | conn->disconn_cfm_cb = NULL; |
3064 | 3064 | ||
3065 | hci_conn_drop(conn); | 3065 | hci_conn_drop(conn); |
3066 | hci_conn_put(conn); | ||
3066 | 3067 | ||
3067 | mgmt_pending_remove(cmd); | 3068 | mgmt_pending_remove(cmd); |
3068 | } | 3069 | } |
@@ -3212,7 +3213,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3212 | } | 3213 | } |
3213 | 3214 | ||
3214 | conn->io_capability = cp->io_cap; | 3215 | conn->io_capability = cp->io_cap; |
3215 | cmd->user_data = conn; | 3216 | cmd->user_data = hci_conn_get(conn); |
3216 | 3217 | ||
3217 | if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && | 3218 | if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && |
3218 | hci_conn_security(conn, sec_level, auth_type, true)) | 3219 | hci_conn_security(conn, sec_level, auth_type, true)) |
@@ -4914,6 +4915,7 @@ static void get_conn_info_complete(struct pending_cmd *cmd, void *data) | |||
4914 | match->mgmt_status, &rp, sizeof(rp)); | 4915 | match->mgmt_status, &rp, sizeof(rp)); |
4915 | 4916 | ||
4916 | hci_conn_drop(conn); | 4917 | hci_conn_drop(conn); |
4918 | hci_conn_put(conn); | ||
4917 | 4919 | ||
4918 | mgmt_pending_remove(cmd); | 4920 | mgmt_pending_remove(cmd); |
4919 | } | 4921 | } |
@@ -5070,7 +5072,7 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data, | |||
5070 | } | 5072 | } |
5071 | 5073 | ||
5072 | hci_conn_hold(conn); | 5074 | hci_conn_hold(conn); |
5073 | cmd->user_data = conn; | 5075 | cmd->user_data = hci_conn_get(conn); |
5074 | 5076 | ||
5075 | conn->conn_info_timestamp = jiffies; | 5077 | conn->conn_info_timestamp = jiffies; |
5076 | } else { | 5078 | } else { |
@@ -5134,8 +5136,10 @@ send_rsp: | |||
5134 | cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(status), | 5136 | cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(status), |
5135 | &rp, sizeof(rp)); | 5137 | &rp, sizeof(rp)); |
5136 | mgmt_pending_remove(cmd); | 5138 | mgmt_pending_remove(cmd); |
5137 | if (conn) | 5139 | if (conn) { |
5138 | hci_conn_drop(conn); | 5140 | hci_conn_drop(conn); |
5141 | hci_conn_put(conn); | ||
5142 | } | ||
5139 | 5143 | ||
5140 | unlock: | 5144 | unlock: |
5141 | hci_dev_unlock(hdev); | 5145 | hci_dev_unlock(hdev); |
@@ -5198,7 +5202,7 @@ static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data, | |||
5198 | 5202 | ||
5199 | if (conn) { | 5203 | if (conn) { |
5200 | hci_conn_hold(conn); | 5204 | hci_conn_hold(conn); |
5201 | cmd->user_data = conn; | 5205 | cmd->user_data = hci_conn_get(conn); |
5202 | 5206 | ||
5203 | hci_cp.handle = cpu_to_le16(conn->handle); | 5207 | hci_cp.handle = cpu_to_le16(conn->handle); |
5204 | hci_cp.which = 0x01; /* Piconet clock */ | 5208 | hci_cp.which = 0x01; /* Piconet clock */ |