diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-09-28 07:28:50 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-10-01 11:02:12 -0400 |
commit | bc8dce4f7b4908bac69acac34d19b4234ba19cee (patch) | |
tree | 2dda8509eb59e2f216a0a51087e2a8d1b0a87e2c | |
parent | 9cb23dd4b6361538eeca33f463b649e8939edde1 (diff) |
Bluetooth: A2MP: Fix potential NULL dereference
Return INVALID_CTRL_ID for unknown AMP controller and for BR/EDR
controller and fixes dereference possible NULL pointer.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | net/bluetooth/a2mp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 42788cdbb4fe..d4946b591b71 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -278,7 +278,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
278 | BT_DBG("id %d", req->id); | 278 | BT_DBG("id %d", req->id); |
279 | 279 | ||
280 | hdev = hci_dev_get(req->id); | 280 | hdev = hci_dev_get(req->id); |
281 | if (!hdev) { | 281 | if (!hdev || hdev->dev_type != HCI_AMP) { |
282 | struct a2mp_info_rsp rsp; | 282 | struct a2mp_info_rsp rsp; |
283 | 283 | ||
284 | rsp.id = req->id; | 284 | rsp.id = req->id; |
@@ -286,14 +286,16 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
286 | 286 | ||
287 | a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), | 287 | a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), |
288 | &rsp); | 288 | &rsp); |
289 | } | ||
290 | 289 | ||
291 | if (hdev->dev_type != HCI_BREDR) { | 290 | goto done; |
292 | mgr->state = READ_LOC_AMP_INFO; | ||
293 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL); | ||
294 | } | 291 | } |
295 | 292 | ||
296 | hci_dev_put(hdev); | 293 | mgr->state = READ_LOC_AMP_INFO; |
294 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL); | ||
295 | |||
296 | done: | ||
297 | if (hdev) | ||
298 | hci_dev_put(hdev); | ||
297 | 299 | ||
298 | skb_pull(skb, sizeof(*req)); | 300 | skb_pull(skb, sizeof(*req)); |
299 | return 0; | 301 | return 0; |