Bluetooth: ATT: Fix not releasing buffer before calling the callback

The cloned buffer is used to retry in case a security error happen but
since the buffer pool is now limited the callback may actually block if
it creates a new request which would need 2 buffers (original + clone)
but only one is available since the previous request clone is not
released yet.

Change-Id: Ife508b09c4b326b8213fd0b130ebf3c2e7fe47c9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2015-11-09 13:23:22 +02:00 committed by Anas Nashif
commit bb27219ecb

View file

@ -190,6 +190,12 @@ static uint8_t att_handle_rsp(struct bt_att *att, void *pdu, uint16_t len,
return 0; return 0;
} }
/* Release cloned buffer */
if (att->req.buf) {
net_buf_unref(att->req.buf);
att->req.buf = NULL;
}
/* Reset request before callback so another request can be queued */ /* Reset request before callback so another request can be queued */
memcpy(&req, &att->req, sizeof(req)); memcpy(&req, &att->req, sizeof(req));
att->req.func = NULL; att->req.func = NULL;