diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2021-04-29 19:16:47 +0300 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-05-07 14:04:49 +0300 |
commit | ea58b568b2335acc8c354aad8bc73e9b0b169f8a (patch) | |
tree | d691a57d265f6082c2d8ce78c65d6afbb153ff73 /helper/cli.c | |
parent | 5006c1738715aded3a5306d22028b38b54bf4ed4 (diff) |
helper: cli: fix odph_cli_start() error handling
When encountering an error in odph_cli_start(), close only file
descriptors that are open, and free shm.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'helper/cli.c')
-rw-r--r-- | helper/cli.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/helper/cli.c b/helper/cli.c index dd4b5fe4f..c2202d079 100644 --- a/helper/cli.c +++ b/helper/cli.c @@ -533,11 +533,16 @@ int odph_cli_start(const odp_instance_t instance, return 0; error: - close(shm->sp[SP_READ]); - close(shm->sp[SP_WRITE]); - close(shm->listen_fd); - close(shm->cli_fd); - shm->run = 0; + if (shm->sp[SP_READ] >= 0) + close(shm->sp[SP_READ]); + if (shm->sp[SP_WRITE] >= 0) + close(shm->sp[SP_WRITE]); + if (shm->listen_fd >= 0) + close(shm->listen_fd); + if (shm->cli_fd >= 0) + close(shm->cli_fd); + if (odp_shm_free(shm_hdl)) + ODPH_ERR("Error: odp_shm_free() failed\n"); return -1; } |