]> git.droids-corp.org - dpdk.git/commitdiff
telemetry: fix race on callbacks list
authorCiara Power <ciara.power@intel.com>
Wed, 5 May 2021 15:22:48 +0000 (15:22 +0000)
committerDavid Marchand <david.marchand@redhat.com>
Wed, 5 May 2021 16:21:26 +0000 (18:21 +0200)
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: f38748736eb2 ("telemetry: add default callback commands")
Cc: stable@dpdk.org
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>
lib/telemetry/telemetry.c

index c06de4553110711e1b1e944ff6a79f387d390375..f8b0d1157ba1514a2a9f7c6e8863e4453a469b32 100644 (file)
@@ -107,8 +107,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;
 }