Skip to content

Commit 30cc718

Browse files
pdgendtnashif
authored andcommitted
net: lib: coap: Return an error on removing a non-existing observer
If we're parsing a CoAP request with an observe option of '1', but there is no matching observer, return an error instead of returning a zero. Signed-off-by: Pieter De Gendt <[email protected]> (cherry picked from commit d5931ba)
1 parent be9fab3 commit 30cc718

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/lib/coap/coap_server.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ int coap_resource_parse_observe(struct coap_resource *resource, const struct coa
658658
ret = coap_service_remove_observer(service, resource, addr, token, tkl);
659659
if (ret < 0) {
660660
LOG_WRN("Failed to remove observer (%d)", ret);
661+
goto unlock;
662+
}
663+
664+
if (ret == 0) {
665+
/* Observer not found */
666+
ret = -ENOENT;
661667
}
662668
}
663669

0 commit comments

Comments
 (0)