diff --git a/subsys/net/lib/coap/coap.c b/subsys/net/lib/coap/coap.c index 25aa1691638..a1c9c2f2f8c 100644 --- a/subsys/net/lib/coap/coap.c +++ b/subsys/net/lib/coap/coap.c @@ -493,11 +493,7 @@ static int parse_option(uint8_t *data, uint16_t offset, uint16_t *pos, return -EINVAL; } - if (r == 0) { - if (len == 0U) { - return r; - } - + if (r == 0 && len != 0U) { /* r == 0 means no more data to read from fragment, but len * field shows that packet should contain more data, it must * be a malformed packet.