nimble/gap: Change ext adv data API to consume mbufs
Setting ext adv data will now consume mbuf regardless of result which
is similar to many other APIs in Mynewt.
X-Original-Commit:
@@ -2853,20 +2853,23 @@ ble_gap_ext_adv_set_data(uint8_t instance, struct os_mbuf *data)
int rc;
if (instance >= BLE_ADV_INSTANCES) {
- return BLE_HS_EINVAL;
+ rc = BLE_HS_EINVAL;
+ goto done;
}
ble_hs_lock();
rc = ble_gap_ext_adv_set_data_validate(instance, data);
if (rc != 0) {
ble_hs_unlock();
- return rc;
+ goto done;
}
rc = ble_gap_ext_adv_set(instance, BLE_HCI_OCF_LE_SET_EXT_ADV_DATA, data);
ble_hs_unlock();
+done:
+ os_mbuf_free_chain(data);
return rc;
}
@@ -2914,14 +2917,15 @@ ble_gap_ext_adv_rsp_set_data(uint8_t instance, struct os_mbuf *data)
int rc;
if (instance >= BLE_ADV_INSTANCES) {
- return BLE_HS_EINVAL;
+ rc = BLE_HS_EINVAL;
+ goto done;
}
ble_hs_lock();
rc = ble_gap_ext_adv_rsp_set_validate(instance, data);
if (rc != 0) {
ble_hs_unlock();
- return rc;
+ goto done;
}
rc = ble_gap_ext_adv_set(instance, BLE_HCI_OCF_LE_SET_EXT_SCAN_RSP_DATA,
@@ -2929,6 +2933,8 @@ ble_gap_ext_adv_rsp_set_data(uint8_t instance, struct os_mbuf *data)
ble_hs_unlock();
+done:
+ os_mbuf_free_chain(data);
return rc;
}
