Skip to contentSkip to conversation

bluetooth:Fix error handling in the function hci_inquiry_cache_update

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

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

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

This fixes error handling in the function hci_inquiry_cache_update for checking if the call to the function hci_remove_oob_data has failed by returning the error code -ENOENT and if so exit immediately to the caller of the function hci_inquiry_cache_update by returning the error code -ENOENT to signal that the call to this function has failed.

---
 net/bluetooth/hci_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +2 -1
index 2f8fb33..ae1bb3d 100644
@@ -1136,7 +1136,8 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
 
 	BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
 
-	hci_remove_remote_oob_data(hdev, &data->bdaddr, BDADDR_BREDR);
+	if (hci_remove_remote_oob_data(hdev, &data->bdaddr, BDADDR_BREDR))
+		return -ENOENT;
 
 	if (!data->ssp_mode)
 		flags |= MGMT_DEV_FOUND_LEGACY_PAIRING;
Signature · 1 line
2.1.4
#1 lore raw

Hi Nicholas,

(again unneeded recipients removed from CC)

Quoted 17 lines · Nicholas Krause

This fixes error handling in the function hci_inquiry_cache_update for checking if the call to the function hci_remove_oob_data has failed by returning the error code -ENOENT and if so exit immediately to the caller of the function hci_inquiry_cache_update by returning the error code -ENOENT to signal that the call to this function has failed.

---
 net/bluetooth/hci_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +0 -0
index 2f8fb33..ae1bb3d 100644

net/bluetooth/hci_core.c u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, · line 1143

Quoted 9 lines
net/bluetooth/hci_core.c +2 -1
@@ -1136,7 +1136,8 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
 
 	BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
 
-	hci_remove_remote_oob_data(hdev, &data->bdaddr, BDADDR_BREDR);
+	if (hci_remove_remote_oob_data(hdev, &data->bdaddr, BDADDR_BREDR))
+		return -ENOENT;
 
 	if (!data->ssp_mode)
 		flags |= MGMT_DEV_FOUND_LEGACY_PAIRING;

This patch is wrong for several reasons. Firstly, this function returns returns u32 so trying to return -ENOENT makes no sense. Secondly, it's normal for hci_remove_remote_oob_data() to fail in this scenario so we can safely ignore its return value.

Johan