Skip to contentSkip to conversation

bluetooth:Fix error handling in the function a2mp_getinfo_req

PATCH In review Nicholas Krause 2 participants 2 messages Aug 20, 2015 – Aug 24, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bluetooth:Fix error handling in the function a2mp_getinfo_req

This fixes error handling in the function a2mp_getinfo_req by assigning the return value of the internal call to the function hci_send_cmd to a new variable, err and returning this value at the end of this function's body as we need to cleanup allocated resources used by this function before signaling to the caller that a internal failure has occurred that is required to be handled by the caller of the function a2mp_getinfo_req.

---
 net/bluetooth/a2mp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/bluetooth/a2mp.c +3 -2
index 5a04eb1..d230a38 100644
@@ -291,6 +291,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
 {
 	struct a2mp_info_req *req  = (void *) skb->data;
 	struct hci_dev *hdev;
+	int err;
 
 	if (le16_to_cpu(hdr->len) < sizeof(*req))
 		return -EINVAL;
@@ -311,14 +312,14 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
 	}
 
 	set_bit(READ_LOC_AMP_INFO, &mgr->state);
-	hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
+	err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
 
 done:
 	if (hdev)
 		hci_dev_put(hdev);
 
 	skb_pull(skb, sizeof(*req));
-	return 0;
+	return err;
 }
 
 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
Signature · 1 line
2.1.4
#1 lore raw

Hi Nicholas,

Quoted 30 lines · Nicholas Krause

This fixes error handling in the function a2mp_getinfo_req by assigning the return value of the internal call to the function hci_send_cmd to a new variable, err and returning this value at the end of this function's body as we need to cleanup allocated resources used by this function before signaling to the caller that a internal failure has occurred that is required to be handled by the caller of the function a2mp_getinfo_req.

---
 net/bluetooth/a2mp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/bluetooth/a2mp.c +1 -1
index 5a04eb1..d230a38 100644
@@ -291,6 +291,7 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
 {
 	struct a2mp_info_req *req  = (void *) skb->data;
 	struct hci_dev *hdev;
+	int err;
 
 	if (le16_to_cpu(hdr->len) < sizeof(*req))
 		return -EINVAL;
@@ -311,14 +312,14 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
 	}
 
 	set_bit(READ_LOC_AMP_INFO, &mgr->state);
-	hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);

net/bluetooth/a2mp.c static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, · line 323

Quoted 10 lines
net/bluetooth/a2mp.c +2 -1
+	err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
 
 done:
 	if (hdev)
 		hci_dev_put(hdev);
 
 	skb_pull(skb, sizeof(*req));
-	return 0;
+	return err;
 }

This patch will not apply against the latest bluetooth-next tree since there the error handling (and A2MP response sending) already seems to be handled correctly.

Johan