Skip to content

Commit

Permalink
telemetry: fix race on callbacks list
Browse files Browse the repository at this point in the history
[ upstream commit 0489602 ]

The list_commands() function accessed the callbacks list,
but did not take the lock. This may have caused inconsistencies if
callbacks were being registered at the same time.
This is now fixed to lock before iterating the list,
and unlock afterwards.

Fixes: f387487 ("telemetry: add default callback commands")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  • Loading branch information
ciarapow authored and steevenlee committed Jun 8, 2021
1 parent 3161953 commit b6659fa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/librte_telemetry/telemetry.c
Expand Up @@ -95,8 +95,10 @@ list_commands(const char *cmd __rte_unused, const char *params __rte_unused,
int i;

rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
rte_spinlock_lock(&callback_sl);
for (i = 0; i < num_callbacks; i++)
rte_tel_data_add_array_string(d, callbacks[i].cmd);
rte_spinlock_unlock(&callback_sl);
return 0;
}

Expand Down

0 comments on commit b6659fa

Please sign in to comment.