BLE Host - Free mbufs on exec-write-failure The previous fix didn't fix an mbuf leak. It added one! The real bug was that an exec-write-response (success) gets sent when a write fails. This commit fixes the mbuf leak that was introduced.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/de85f43d Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/de85f43d Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/de85f43d Branch: refs/heads/sterly_refactor Commit: de85f43dec28a329d5b937936045ba840423318f Parents: aadba62 Author: Christopher Collins <[email protected]> Authored: Sun Aug 7 02:34:00 2016 -0700 Committer: Sterling Hughes <[email protected]> Committed: Tue Aug 9 16:05:21 2016 -0700 ---------------------------------------------------------------------- net/nimble/host/src/ble_att_svr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/de85f43d/net/nimble/host/src/ble_att_svr.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c index b3dd2f3..1b420b5 100644 --- a/net/nimble/host/src/ble_att_svr.c +++ b/net/nimble/host/src/ble_att_svr.c @@ -2342,16 +2342,19 @@ ble_att_svr_prep_write(uint16_t conn_handle, ble_att_svr_prep_extract(prep_list, &attr_handle, &om); attr = ble_att_svr_find_by_handle(attr_handle); + *err_handle = attr_handle; if (attr == NULL) { rc = BLE_ATT_ERR_INVALID_HANDLE; - *err_handle = attr_handle; } else { rc = ble_att_svr_write(conn_handle, attr, 0, &om, &att_err); - os_mbuf_free_chain(om); if (rc != 0) { - return att_err; + rc = att_err; } } + os_mbuf_free_chain(om); + if (rc != 0) { + return rc; + } } return 0;
