summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-data.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-02-25 00:15:28 +0100
committerSander Vrijders <sander@ouroboros.rocks>2022-03-03 12:00:53 +0100
commit27374c05645cb6a656e82a9a0b6bc810082cfe4e (patch)
tree9177d572965d352ca606e5535a5971e91fddde4a /src/ipcpd/shim-data.c
parent9719dbe335af4c6add39d739f78a68040b62d8a3 (diff)
downloadouroboros-27374c05645cb6a656e82a9a0b6bc810082cfe4e.tar.gz
ouroboros-27374c05645cb6a656e82a9a0b6bc810082cfe4e.zip
ipcpd: Fix some unchecked return values
Fixes some unchecked and wrongly checked return values. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/shim-data.c')
-rw-r--r--src/ipcpd/shim-data.c22
1 files changed, 18 insertions, 4 deletions
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)