1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gcoap: Avoid lockup from error paths

This commit is contained in:
chrysn 2024-04-06 11:37:35 +02:00
parent 502406dbbb
commit 2f7cbd3e1f

View File

@ -1657,6 +1657,9 @@ ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
ssize_t res = _cache_check(buf, len, memo, &cache_hit);
if (res < 0) {
DEBUG("gcoap: Error from cache check");
memo->state = GCOAP_MEMO_UNUSED;
mutex_unlock(&_coap_state.lock);
return res;
}
len = res;
@ -1667,6 +1670,9 @@ ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
/* Can't store it for retransmission, even though sending it from
* the provided buffer once is possible */
if (len > CONFIG_GCOAP_PDU_BUF_SIZE) {
DEBUG("gcoap: Request too large for retransmit buffer");
memo->state = GCOAP_MEMO_UNUSED;
mutex_unlock(&_coap_state.lock);
return -EINVAL;
}