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 | |
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')
-rw-r--r-- | net/bluetooth/hci_conn.c | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 9 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 3 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 12 |
4 files changed, 18 insertions, 7 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index faff6247ac8f..4ecc9d5fce7a 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -595,6 +595,7 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status) | |||
595 | conn->dst_type); | 595 | conn->dst_type); |
596 | if (params && params->conn) { | 596 | if (params && params->conn) { |
597 | hci_conn_drop(params->conn); | 597 | hci_conn_drop(params->conn); |
598 | hci_conn_put(params->conn); | ||
598 | params->conn = NULL; | 599 | params->conn = NULL; |
599 | } | 600 | } |
600 | 601 | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9b7145959a49..ed60d37ea646 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2541,6 +2541,7 @@ static void hci_pend_le_actions_clear(struct hci_dev *hdev) | |||
2541 | list_for_each_entry(p, &hdev->le_conn_params, list) { | 2541 | list_for_each_entry(p, &hdev->le_conn_params, list) { |
2542 | if (p->conn) { | 2542 | if (p->conn) { |
2543 | hci_conn_drop(p->conn); | 2543 | hci_conn_drop(p->conn); |
2544 | hci_conn_put(p->conn); | ||
2544 | p->conn = NULL; | 2545 | p->conn = NULL; |
2545 | } | 2546 | } |
2546 | list_del_init(&p->action); | 2547 | list_del_init(&p->action); |
@@ -3734,8 +3735,10 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type) | |||
3734 | if (!params) | 3735 | if (!params) |
3735 | return; | 3736 | return; |
3736 | 3737 | ||
3737 | if (params->conn) | 3738 | if (params->conn) { |
3738 | hci_conn_drop(params->conn); | 3739 | hci_conn_drop(params->conn); |
3740 | hci_conn_put(params->conn); | ||
3741 | } | ||
3739 | 3742 | ||
3740 | list_del(¶ms->action); | 3743 | list_del(¶ms->action); |
3741 | list_del(¶ms->list); | 3744 | list_del(¶ms->list); |
@@ -3767,8 +3770,10 @@ void hci_conn_params_clear_all(struct hci_dev *hdev) | |||
3767 | struct hci_conn_params *params, *tmp; | 3770 | struct hci_conn_params *params, *tmp; |
3768 | 3771 | ||
3769 | list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) { | 3772 | list_for_each_entry_safe(params, tmp, &hdev->le_conn_params, list) { |
3770 | if (params->conn) | 3773 | if (params->conn) { |
3771 | hci_conn_drop(params->conn); | 3774 | hci_conn_drop(params->conn); |
3775 | hci_conn_put(params->conn); | ||
3776 | } | ||
3772 | list_del(¶ms->action); | 3777 | list_del(¶ms->action); |
3773 | list_del(¶ms->list); | 3778 | list_del(¶ms->list); |
3774 | kfree(params); | 3779 | kfree(params); |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d2ee162ecddb..e6a496ae0318 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -4231,6 +4231,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4231 | list_del_init(¶ms->action); | 4231 | list_del_init(¶ms->action); |
4232 | if (params->conn) { | 4232 | if (params->conn) { |
4233 | hci_conn_drop(params->conn); | 4233 | hci_conn_drop(params->conn); |
4234 | hci_conn_put(params->conn); | ||
4234 | params->conn = NULL; | 4235 | params->conn = NULL; |
4235 | } | 4236 | } |
4236 | } | 4237 | } |
@@ -4322,7 +4323,7 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr, | |||
4322 | * the parameters get removed and keep the reference | 4323 | * the parameters get removed and keep the reference |
4323 | * count consistent once the connection is established. | 4324 | * count consistent once the connection is established. |
4324 | */ | 4325 | */ |
4325 | params->conn = conn; | 4326 | params->conn = hci_conn_get(conn); |
4326 | return; | 4327 | return; |
4327 | } | 4328 | } |
4328 | 4329 | ||
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 */ |