Skip to content

Commit f4b768a

Browse files
pdgendtgithub-actions[bot]
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 4189364 commit f4b768a

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
@@ -697,6 +697,12 @@ int coap_resource_parse_observe(struct coap_resource *resource, const struct coa
697697
ret = coap_service_remove_observer(service, resource, addr, token, tkl);
698698
if (ret < 0) {
699699
LOG_WRN("Failed to remove observer (%d)", ret);
700+
goto unlock;
701+
}
702+
703+
if (ret == 0) {
704+
/* Observer not found */
705+
ret = -ENOENT;
700706
}
701707
}
702708

0 commit comments

Comments
 (0)