samples: ipc: openamp_rsc_table: Check for endpoint create failure

Check if creating the RPMSG endpoint fails and exit the task if so.
This prevents a later null pointer dereference if we try to continue.

Signed-off-by: Andrew Davis <afd@ti.com>
This commit is contained in:
Andrew Davis 2024-03-11 10:46:44 -05:00 committed by David Leach
parent 688fbb53ae
commit 27cb75edb8

View file

@ -291,6 +291,10 @@ void app_rpmsg_client_sample(void *arg1, void *arg2, void *arg3)
ret = rpmsg_create_ept(&sc_ept, rpdev, "rpmsg-client-sample", ret = rpmsg_create_ept(&sc_ept, rpdev, "rpmsg-client-sample",
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
rpmsg_recv_cs_callback, NULL); rpmsg_recv_cs_callback, NULL);
if (ret) {
LOG_ERR("[Linux sample client] Could not create endpoint: %d\n", ret);
goto task_end;
}
while (msg_cnt < 100) { while (msg_cnt < 100) {
k_sem_take(&data_sc_sem, K_FOREVER); k_sem_take(&data_sc_sem, K_FOREVER);
@ -301,6 +305,7 @@ void app_rpmsg_client_sample(void *arg1, void *arg2, void *arg3)
} }
rpmsg_destroy_ept(&sc_ept); rpmsg_destroy_ept(&sc_ept);
task_end:
printk("OpenAMP Linux sample client responder ended\n"); printk("OpenAMP Linux sample client responder ended\n");
} }
@ -321,6 +326,10 @@ void app_rpmsg_tty(void *arg1, void *arg2, void *arg3)
ret = rpmsg_create_ept(&tty_ept, rpdev, "rpmsg-tty", ret = rpmsg_create_ept(&tty_ept, rpdev, "rpmsg-tty",
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
rpmsg_recv_tty_callback, NULL); rpmsg_recv_tty_callback, NULL);
if (ret) {
LOG_ERR("[Linux TTY] Could not create endpoint: %d\n", ret);
goto task_end;
}
while (tty_ept.addr != RPMSG_ADDR_ANY) { while (tty_ept.addr != RPMSG_ADDR_ANY) {
k_sem_take(&data_tty_sem, K_FOREVER); k_sem_take(&data_tty_sem, K_FOREVER);
@ -336,6 +345,7 @@ void app_rpmsg_tty(void *arg1, void *arg2, void *arg3)
} }
rpmsg_destroy_ept(&tty_ept); rpmsg_destroy_ept(&tty_ept);
task_end:
printk("OpenAMP Linux TTY responder ended\n"); printk("OpenAMP Linux TTY responder ended\n");
} }