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/shim-data.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/ipcpd/shim-data.c') diff --git a/src/ipcpd/shim-data.c b/src/ipcpd/shim-data.c index ade157ce..761ecc3b 100644 --- a/src/ipcpd/shim-data.c +++ b/src/ipcpd/shim-data.c @@ -141,7 +141,9 @@ static void dir_entry_destroy(struct dir_entry * entry) struct shim_data * shim_data_create() { - struct shim_data * sd = malloc(sizeof(*sd)); + struct shim_data * sd; + + sd = malloc(sizeof(*sd)); if (sd == NULL) return NULL; @@ -151,11 +153,23 @@ struct shim_data * shim_data_create() list_head_init(&sd->dir_queries); /* init the locks */ - pthread_rwlock_init(&sd->reg_lock, NULL); - pthread_rwlock_init(&sd->dir_lock, NULL); - pthread_mutex_init(&sd->dir_queries_lock, NULL); + if (pthread_rwlock_init(&sd->reg_lock, NULL) < 0) + goto fail_reg_lock_init; + + if (pthread_rwlock_init(&sd->dir_lock, NULL) < 0) + goto fail_dir_lock_init; + + if (pthread_mutex_init(&sd->dir_queries_lock, NULL) < 0) + goto fail_mutex_init; return sd; + + fail_mutex_init: + pthread_rwlock_destroy(&sd->dir_lock); + fail_dir_lock_init: + pthread_rwlock_destroy(&sd->reg_lock); + fail_reg_lock_init: + return NULL; } static void clear_registry(struct shim_data * data) -- cgit v1.2.3