net: lib: lwm2m: Fix lwm2m exec

The lwm2m exec erroneously checked the previous return value
instead of checking if the resource existed. This caused exec
to try to get and execute the execute callback from NULL and caused
a reboot.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
This commit is contained in:
Jarno Lämsä 2022-09-15 10:14:26 +03:00 committed by Fabio Baltieri
commit 05b17356e2

View file

@ -117,8 +117,8 @@ static int cmd_exec(const struct shell *sh, size_t argc, char **argv)
struct lwm2m_engine_res *res = lwm2m_engine_get_res(&path);
if (ret < 0) {
shell_error(sh, "Resource not found (err %d)\n", ret);
if (res == NULL) {
shell_error(sh, "Resource not found\n");
return -EINVAL;
}