From 8ae2713477027a229ae4ee7045557151e467aff3 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 14 Mar 2016 11:39:55 +0100 Subject: [PATCH] tsilo: lock before linking var to the entry in slot - entry points to the address of first entry, which can be updated before aquiring the lock --- modules/tsilo/ts_rpc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/tsilo/ts_rpc.c b/modules/tsilo/ts_rpc.c index 20783f487ef..7a3b6595a7a 100644 --- a/modules/tsilo/ts_rpc.c +++ b/modules/tsilo/ts_rpc.c @@ -45,6 +45,9 @@ static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_trans { void* vh; + if(t==NULL) + return -1; + if(rpc->struct_add(ih, "{", "Transaction", &vh)<0) { rpc->fault(ctx, 500, "Internal error creating transaction struct"); @@ -73,9 +76,9 @@ static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_trans */ static void rpc_tsilo_dump(rpc_t *rpc, void *c) { - ts_transaction_t* trans; - struct ts_urecord* record; - struct ts_entry* entry; + ts_transaction_t* trans = NULL; + struct ts_urecord* record = NULL; + struct ts_entry* entry = NULL; str brief = {0, 0}; @@ -115,8 +118,8 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c) /* add the entries per hash */ for(i=0,n=0,max=0,ntrans=0; isize; i++) { + lock_entry(&t_table->entries[i]); entry = &t_table->entries[i]; - lock_entry(entry); n += entry->n; if(maxn) @@ -130,7 +133,7 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c) "Hash", record->rurihash, "Transactions", &ih)<0) { - unlock_entry(entry); + unlock_entry(&t_table->entries[i]); rpc->fault(c, 500, "Internal error creating ruri struct"); return; } @@ -139,13 +142,13 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c) ntrans += 1; if (short_dump==0) { if (rpc_dump_transaction(rpc, c, ih, trans) == -1) { - unlock_entry(entry); + unlock_entry(&t_table->entries[i]); return; } } } } - unlock_entry(entry); + unlock_entry(&t_table->entries[i]); } /* extra attributes node */