Skip to content

Commit

Permalink
gcoap: Avoid lockup from error paths
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Apr 24, 2024
1 parent 502406d commit 2f7cbd3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 2f7cbd3

Please sign in to comment.