Multiple threads calling the same function may cause condition race issues, which often leads to abnormal behavior and can cause more serious vulnerabilities such as abnormal termination, denial of service, and compromised data integrity.
The strtok() is non-reentrant, it is better to replace it with a reentrant version. Fixes: 39b5ab60df30 ("dmadev: add telemetry") Signed-off-by: Jie Hai <haij...@huawei.com> Acked-by: Chengwen Feng <fengcheng...@huawei.com> Acked-by: Morten Brørup <m...@smartsharesystems.com> --- lib/dmadev/rte_dmadev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 8bb7824aa129..eaf649e7d982 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -14,6 +14,7 @@ #include <rte_memzone.h> #include <rte_string_fns.h> #include <rte_telemetry.h> +#include <rte_os_shim.h> #include "rte_dmadev.h" #include "rte_dmadev_pmd.h" @@ -1016,7 +1017,7 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused, struct rte_dma_info dma_info; struct rte_dma_stats dma_stats; int dev_id, ret, vchan_id; - char *end_param; + char *end_param, *sp = NULL; const char *vchan_param; if (params == NULL || strlen(params) == 0 || !isdigit(*params)) @@ -1035,7 +1036,7 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused, if (dma_info.nb_vchans == 1 && *end_param == '\0') vchan_id = 0; else { - vchan_param = strtok(end_param, ","); + vchan_param = strtok_r(end_param, ",", &sp); if (!vchan_param || strlen(vchan_param) == 0 || !isdigit(*vchan_param)) return -EINVAL; -- 2.33.0