From 27374c05645cb6a656e82a9a0b6bc810082cfe4e Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 25 Feb 2022 00:15:28 +0100 Subject: ipcpd: Fix some unchecked return values Fixes some unchecked and wrongly checked return values. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/local/main.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/ipcpd/local') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 9c62c3cc..c0e0b702 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -72,24 +72,28 @@ static int local_data_init(void) local_data.flows = fset_create(); if (local_data.flows == NULL) - return -ENFILE; + goto fail_fset; local_data.fq = fqueue_create(); - if (local_data.fq == NULL) { - fset_destroy(local_data.flows); - return -ENOMEM; - } + if (local_data.fq == NULL) + goto fail_fqueue; local_data.shim_data = shim_data_create(); - if (local_data.shim_data == NULL) { - fqueue_destroy(local_data.fq); - fset_destroy(local_data.flows); - return -ENOMEM; - } - - pthread_rwlock_init(&local_data.lock, NULL); + if (local_data.shim_data == NULL) + goto fail_shim_data; + if (pthread_rwlock_init(&local_data.lock, NULL) < 0) + goto fail_rwlock_init; return 0; + + fail_rwlock_init: + shim_data_destroy(local_data.shim_data); + fail_shim_data: + fqueue_destroy(local_data.fq); + fail_fqueue: + fset_destroy(local_data.flows); + fail_fset: + return -ENOMEM; } static void local_data_fini(void){ -- cgit v1.2.3